java.io.IOException: Unable to establish loopback connection

这篇具有很好参考价值的文章主要介绍了java.io.IOException: Unable to establish loopback connection。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

问题

        在win10电脑上启动SpringBoot项目出现以下报错

org.springframework.context.ApplicationContextException: Failed to start bean 'webServerStartStop'; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:185) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:53) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:360) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:158) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:122) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:895) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:554) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
        at com.zw.msuite.MsuiteApplication.main(MsuiteApplication.java:22) [classes!/:1.0.0]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_202]
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_202]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_202]
        at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_202]
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) [msuite-service-1.0.0.jar:1.0.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:107) [msuite-service-1.0.0.jar:1.0.0]
        at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) [msuite-service-1.0.0.jar:1.0.0]
        at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:88) [msuite-service-1.0.0.jar:1.0.0]
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat server
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
        at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
        at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:182) ~[spring-context-5.2.9.RELEASE.jar!/:5.2.9.RELEASE]
        ... 22 common frames omitted
Caused by: java.lang.IllegalArgumentException: standardService.connector.startFailed
        at org.apache.catalina.core.StandardService.addConnector(StandardService.java:231) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.addPreviouslyRemovedConnectors(TomcatWebServer.java:282) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
        at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:213) ~[spring-boot-2.3.4.RELEASE.jar!/:2.3.4.RELEASE]
        ... 24 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Protocol handler start failed
        at org.apache.catalina.connector.Connector.startInternal(Connector.java:1067) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
        at org.apache.catalina.core.StandardService.addConnector(StandardService.java:227) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
        ... 26 common frames omitted
Caused by: java.io.IOException: Unable to establish loopback connection
        at sun.nio.ch.PipeImpl$Initializer.run(Unknown Source) ~[na:1.8.0_202]
        at sun.nio.ch.PipeImpl$Initializer.run(Unknown Source) ~[na:1.8.0_202]
        at java.security.AccessController.doPrivileged(Native Method) ~[na:1.8.0_202]
        at sun.nio.ch.PipeImpl.<init>(Unknown Source) ~[na:1.8.0_202]
        at sun.nio.ch.SelectorProviderImpl.openPipe(Unknown Source) ~[na:1.8.0_202]
        at java.nio.channels.Pipe.open(Unknown Source) ~[na:1.8.0_202]
        at sun.nio.ch.WindowsSelectorImpl.<init>(Unknown Source) ~[na:1.8.0_202]
        at sun.nio.ch.WindowsSelectorProvider.openSelector(Unknown Source) ~[na:1.8.0_202]
        at java.nio.channels.Selector.open(Unknown Source) ~[na:1.8.0_202]
        at org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector(NioSelectorPool.java:52) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
        at org.apache.tomcat.util.net.NioSelectorPool.close(NioSelectorPool.java:119) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
        at org.apache.tomcat.util.net.NioEndpoint.unbind(NioEndpoint.java:346) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
        at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1146) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
        at org.apache.tomcat.util.net.AbstractEndpoint.start(AbstractEndpoint.java:1227) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
        at org.apache.coyote.AbstractProtocol.start(AbstractProtocol.java:592) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
        at org.apache.catalina.connector.Connector.startInternal(Connector.java:1064) ~[tomcat-embed-core-9.0.38.jar!/:9.0.38]
        ... 28 common frames omitted
Caused by: java.net.ConnectException: Connection timed out: connect
        at sun.nio.ch.Net.connect0(Native Method) ~[na:1.8.0_202]
        at sun.nio.ch.Net.connect(Unknown Source) ~[na:1.8.0_202]
        at sun.nio.ch.Net.connect(Unknown Source) ~[na:1.8.0_202]
        at sun.nio.ch.SocketChannelImpl.connect(Unknown Source) ~[na:1.8.0_202]
        at java.nio.channels.SocketChannel.open(Unknown Source) ~[na:1.8.0_202]
        at sun.nio.ch.PipeImpl$Initializer$LoopbackConnector.run(Unknown Source) ~[na:1.8.0_202]

问题定位和解决

        在上述报错中,标红的那一行是至关重要的报错信息。

Caused by: java.io.IOException: Unable to establish loopback connection

        翻译为中文:不能建立环回连接。而回环地址就是指127.0.0.1。后来想到可能跟我本机配置的IP安全策略有关。有关安全策略的配置见下面博客。

Windows 10 布置IP安全策略_李劭卓保护美好一切的博客-CSDN博客_windows ip安全策略

        我在一条安全策略中,启用了一个"All Deny"的IP筛选器,该筛选器会禁用所有IP访问我的电脑,并放在筛选器列表的最后生效,作为兜底。

        关键在于这个"All Deny"的IP筛选器的目标地址,我配置了"任何IP地址"(如下图),这就导致了环回地址(127.0.0.1)也不能被访问。将目标地址更改为"我的IP地址"之后,上述报错就消失了,服务能够正常启动。

java.io.IOException: Unable to establish loopback connection

 文章来源地址https://www.toymoban.com/news/detail-408715.html

到了这里,关于java.io.IOException: Unable to establish loopback connection的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包