Today I started getting this weird looking exception while launching tomcat.
SEVERE: StandardServer.await: create[localhost:8005]: java.net.BindException: Cannot assign requested address: JVM_Bind at java.net.DualStackPlainSocketImpl.bind0(Native Method) at java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:96) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:376) at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:175) at java.net.ServerSocket.bind(ServerSocket.java:376) at java.net.ServerSocket.<init>(ServerSocket.java:237) at org.apache.catalina.core.StandardServer.await(StandardServer.java:427) at org.apache.catalina.startup.Catalina.await(Catalina.java:766) at org.apache.catalina.startup.Catalina.start(Catalina.java:712) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:322) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:451)
I googled around and most answers were pointing towards Port is already being used, which definitely wasn’t the issue in my case, anyways after spending few hours I figured out my main issue was that my IPV4 address changed. Although I never updated my
server.xml to change localhost to any specific IP address but yet I started getting this error.
The actual cause of this issue was my host file present at WINDOWS_INSTALLTION/windows/System32/drivers/etc, where in which my old IP address was mapped against localhost like below:
127.0.0.1 localhost 192.168.XXX.XX localhost
This second line was the main culprit, there are two ways of solving this:
- Remove 192.168.XXX.XX localhost line completely from host file
- Replace old IP with new IP in your host file i.e instead of 192.168.XXX.XX localhost change it to 192.168.XXX.YY localhost
Hope this helps!