Tomcat java.net.BindException: Cannot assign requested address: JVM_Bind

Today I started getting this weird looking exception while launching tomcat.
[sourcecode language=”java”]
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)
[/sourcecode]
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:

[sourcecode langugage=”txt” highlight=”2″]
127.0.0.1 localhost
192.168.XXX.XX localhost
[/sourcecode]
This second line was the main culprit, there are two ways of solving this:

  1. Remove 192.168.XXX.XX localhost line completely from host file
  2. 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!


Posted

in

,

by

Tags:

Comments

22 responses to “Tomcat java.net.BindException: Cannot assign requested address: JVM_Bind”

  1. seenu Avatar
    seenu

    very nice one its really helped me.

    thank you alot.. 🙂

  2. Mohd Rashid Avatar
    Mohd Rashid

    Really very nice.. it helps me a lot. i was stuck and try to close the services and ports so many times.. but it was Host.. 😉

    1. Prabhat Jha Avatar

      Glad I was of some help happy coding 🙂

  3. venkat Avatar
    venkat

    Wow … you saved my day … really very helpful … Thanks a lot 🙂

  4. anil Avatar
    anil

    thanks it realy helped me

  5. Abid Avatar
    Abid

    thanks dude..

  6. asdf Avatar
    asdf

    this worked for me! thanks!

  7. vidhyadharan D (@vidhya_java) Avatar

    Thanks a lot .. Valuable info

  8. DK Avatar
    DK

    Thanks alot…spent lot of time resolving this issue….finally found the solution 🙂

  9. Michael Avatar
    Michael

    I suggest you create a question in stackoverflow and link
    this blog entry as an answer.

  10. sunny Avatar
    sunny

    Wonderful it fixed my issue…

  11. chandra Avatar
    chandra

    Lots of thanks you dear

  12. tets Avatar
    tets

    It did help Thanks

  13. Leo Bi Avatar

    Thanks a lot! I had tried so many approaches, and finally this article helped me out! It is because my workstation IP had been changed recently but I didn’t realize it. Orz

  14. colboy Avatar
    colboy

    HAH! why on earth did i miss that! thanks a lot!

  15. Harinath Avatar

    yup, I changed my hosts file when I was in different network. now I started getting this error since. updated hosts file to look normal. then it started working fine.

  16. Kir Avatar
    Kir

    Yes! it was really hepful!

  17. asraful Avatar

    man you saved my day , exact answer it is ,

  18. Justin Avatar
    Justin

    Wow Great buddy..Really helpfull uffffffff 🙂

  19. Rahh Avatar
    Rahh

    Thank you….it really helpedme

    1. Sasi Avatar
      Sasi

      Glad I visited this page. Thanks man!

Leave a Reply to anilCancel reply

Discover more from Code Holic

Subscribe now to keep reading and get access to the full archive.

Continue reading