首页 > 代码库 > java.net.BindException: Cannot assign requested address

java.net.BindException: Cannot assign requested address

 

tomcat启动后报错

2017-6-7 17:23:49 org.apache.catalina.core.StandardServer await
严重: StandardServer.await: create[localhost:8005]: 
java.net.BindException: Cannot assign requested address
        at java.net.PlainSocketImpl.socketBind(Native Method)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:365)
        at java.net.ServerSocket.bind(ServerSocket.java:319)
        at java.net.ServerSocket.<init>(ServerSocket.java:185)
        at org.apache.catalina.core.StandardServer.await(StandardServer.java:422)
        at org.apache.catalina.startup.Catalina.await(Catalina.java:707)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:653)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:303)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)
2017-6-7 17:23:49 org.apache.coyote.AbstractProtocolHandler pause
信息: Pausing ProtocolHandler ["http-bio-8080"]
2017-6-7 17:06:51 org.apache.coyote.AbstractProtocolHandler pause
信息: Pausing ProtocolHandler ["ajp-bio-8009"]
2017-6-7 17:23:57 org.apache.catalina.core.StandardService stopInternal
信息: Stopping service Catalina
2017-6-7 17:23:57 org.apache.coyote.AbstractProtocolHandler stop
信息: Stopping ProtocolHandler ["http-bio-8080"]
2017-6-7 17:23:57 org.apache.coyote.AbstractProtocolHandler stop
信息: Stopping ProtocolHandler ["ajp-bio-8009"]
 
原因是:hosts中的localhost对应的IP地址非本机地址
 
修改正确重启tomcat即正常
10.1.170.16   localhost.localdomain localhost

 

java.net.BindException: Cannot assign requested address