Tomcat startup gave the notorious
java.net.BindException: Cannot assign requested address
. This usually means that another process is listening on the same port on this machine. I started with ps -ef grep java
to make sure that no other tomcat process was running on the machine. Nothing.I suspected that maybe some other web server was holding the port, but
netstat -an
showed that nothing binds this address. Moreover, telnet localhost 80
showed that no one is listening.Looking at the server.xml I found out that the connector was binding to the hostname "demoserver" on port 80.
<Connector className="org.apache.coyote.tomcat4.CoyoteConnector"
address="demoserver" port="80"
minProcessors="5" maxProcessors="75"
enableLookups="true" redirectPort="8443"
acceptCount="100" debug="0" connectionTimeout="20000"
useURIValidationHack="false" disableUploadTimeout="true" />
trying to
ping demoserver
gave me errors, but nslookup demoserver
gave me the right ip address.After a few minutes I noticed that some clown added demoserver to
/etc/hosts
with the wrong ip address. Fixing /etc/hosts to have the right ip address for demoserver made tomcat work smooth and nice.
Great tip. This helped me solve the exact same problem.
ReplyDeleteThanks a lot, had the exact same problem.
ReplyDeleteThis is what I just need.
ReplyDeleteMany thanks :-)
You're awesome! Saved me a lot of time and head banging....
ReplyDeleteHey I had a similar issue with Weblogic 10 starting the nodemanager - and your comment fixed it - someone had put the wrong ip address of my server in /etc/hosts - thanks!!!
ReplyDeletehave same problem but not on linux, its on vista. can i be helped ?
ReplyDeletecheers! had a duplicate and inccorect entry in hosts file for localhost. removed it and it worked fine!
ReplyDeleteThanks, had the same issue on linux.
ReplyDeleteSame issue here, thanks so much!
ReplyDeleteThanks!
ReplyDeleteThanks! Also fixed an issue for me (bad entry in the /etc/hosts file), Java app in question was an AR System Plug-in Server. Seems like the same message is used for cases where the TCP port the bind is trying is in use, so the message was just a bit too generic.
ReplyDeletethis tip helped me as i noticed that the error msg is related to ip address in case i had to request ip and port open on the LoadBalncer
ReplyDeletethanx
thanks a lot. even we are facing same issue. we added an entry for localhost into /etc/hosts then our server started without any problem
ReplyDeleteSaved me some time here thank you very much.
ReplyDeleteIt works great!!! Thanks a lot my friend!!!
ReplyDeletethanks dude
ReplyDeleteworked like a charm with glassfish
We got a similar error doing an ftp connection with a java application, using sunone appserver 8.2.
ReplyDeleteThe issue was solved adding the following jvm option to the appserver and restarting it.
-Dcom.sun.enterprise.server.ss.ASQuickStartup=false
Hope it will help ...
Regards.
Elibm
You made my day! Big Thx !
ReplyDeleteGreat article!
ReplyDeleteIn my case QA guys simply deleted the following mandatory lines in /etc/hosts:
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
Good one short and clear. here is my way of solving Java.net.BindException: Address already in use: JVM_Bind
ReplyDeleteThanks..worked for me...I checked /etc/host but did not find that same IP 127.0.0.1 has two different host
ReplyDeleteDear all,
ReplyDeleteI am happy that after 4 years this post (one of the first I wrote) is still very helpful and all the more relevant.
Thank you for the comments...
Still useful in 2012. Upgrading from Tomcat5 to Tomcat6. Worked all fine in Tomat5, but with Tomcat6 it could not bind to the shutdown port. After finding this post, I noticed that the hosts file contained a typo "i127.0.0.1". This server was running for the last 6 years with that ;)
ReplyDeletereally works! thanks a lot
ReplyDeletegreat dude..it worked for me also..saved time
ReplyDeletethanks dude, This post saved me tons of headache
ReplyDelete