Tomcat startup, 8080 address already in use
Solution 1
I also had the same issue. Tried all the options suggested in this thread. But didnt help. Then just did ran:
ps -awwef | grep tomcat
and found some stale process running. I killed it using (-15 instead of -9)
sudo kill -15 <tomcat pid from previous command>
And woot! it worked. Restarted tomcat without any issue.
Solution 2
NEVER kill a process with signal -9, because this type of killing process leaves its resources present in the system, which can only be removed after a server reboot. only use kill -9 only in extreme emergency. better to use kill -15, as it might take some time to cleanup resources, but you would always get proper flushing of that whole set of resources, that the process is consuming. so most probably, the tomcat is not working as it has left some of the resources left in the memory. So, either perform a reboot or try to find following:
- through lsof command and grep it with tomcat. it will show you anything that has tomcat associated with it
lsof | grep tomcat
- search of any pid lock file on filesystem, left by tomcat.
- Also try to issue:
lsof -i TCP | grep 8080
Solution 3
The port number is configured in $TOMCAT_HOME/conf/server.xml
If port 8080 is in use, change it in the server.xml file. Mine looks like this in server.xml
<Connector port="8085" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
Solution 4
Just running a lsof may be not enough. I suggest this command:
sudo lsof -i :8080
And then you can kill whatever process is holding the port (most probably another instance of tomcat).
Solution 5
Just for the record: I got this error (as a newbie) because I started Apache before starting Tomcat.
If I stopped Apache, then started Tomcat and then started Apache, the errors disappeared.
Related videos on Youtube
marko
Updated on July 09, 2022Comments
-
marko almost 2 years
The setup is:
- Amazon EC2
- Tomcat (with secure forwarding to 8443)
- Apache 2.2
I run the shutdown.sh, and I get no errors.
BUT when I try to runt the startup.sh I get this error:
07-Nov-2011 17:40:40 org.apache.catalina.core.AprLifecycleListener init INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/i386/client:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/lib/i386:/usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0/jre/../lib/i386:/usr/java/packages/lib/i386:/lib:/usr/lib 07-Nov-2011 17:40:41 org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8080 07-Nov-2011 17:40:41 org.apache.coyote.http11.Http11Protocol init SEVERE: Error initializing endpoint java.net.BindException: Address already in use <null>:8080 at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:549) at org.apache.coyote.http11.Http11Protocol.init(Http11Protocol.java:176) at org.apache.catalina.connector.Connector.initialize(Connector.java:1022) at org.apache.catalina.core.StandardService.initialize(StandardService.java:703) at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:838) at org.apache.catalina.startup.Catalina.load(Catalina.java:538) at org.apache.catalina.startup.Catalina.load(Catalina.java:562) 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:616) at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:261) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) Caused by: java.net.BindException: Address already in use at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:336) at java.net.ServerSocket.bind(ServerSocket.java:336) at java.net.ServerSocket.<init>(ServerSocket.java:202) at java.net.ServerSocket.<init>(ServerSocket.java:158) at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:50) at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:538) ... 12 more 07-Nov-2011 17:40:41 org.apache.catalina.core.StandardService initialize SEVERE: Failed to initialize connector [Connector[HTTP/1.1-8080]] LifecycleException: Protocol handler initialization failed: java.net.BindException: Address already in use <null>:8080 at org.apache.catalina.connector.Connector.initialize(Connector.java:1024) at org.apache.catalina.core.StandardService.initialize(StandardService.java:703) at org.apache.catalina.core.StandardServer.initialize(StandardServer.java:838) at org.apache.catalina.startup.Catalina.load(Catalina.java:538) at org.apache.catalina.startup.Catalina.load(Catalina.java:562) 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:616) at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:261) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413) 07-Nov-2011 17:40:41 org.apache.coyote.http11.Http11Protocol init INFO: Initializing Coyote HTTP/1.1 on http-8443 07-Nov-2011 17:40:41 org.apache.catalina.startup.Catalina load INFO: Initialization processed in 615 ms 07-Nov-2011 17:40:41 org.apache.catalina.core.StandardService start INFO: Starting service Catalina 07-Nov-2011 17:40:41 org.apache.catalina.core.StandardEngine start INFO: Starting service Catalina 07-Nov-2011 17:40:41 org.apache.catalina.core.StandardEngine start INFO: Starting Servlet Engine: Apache Tomcat/6.0.33 07-Nov-2011 17:40:41 org.apache.catalina.startup.HostConfig deployDescriptor INFO: Deploying configuration descriptor host-manager.xml 07-Nov-2011 17:40:41 org.apache.catalina.startup.HostConfig deployDescriptor INFO: Deploying configuration descriptor manager.xml 07-Nov-2011 17:40:41 org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive test.war log4j:WARN No appenders could be found for logger (StackTrace). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info. log4j:ERROR Error initializing log4j: grails/plugins/springsecurity/SecurityConfigType : Unsupported major.minor version 51.0 (unable to load class grails.plugins.springsecurity.SecurityConfigType) java.lang.UnsupportedClassVersionError: grails/plugins/springsecurity/SecurityConfigType : Unsupported major.minor version 51.0 (unable to load class grails.plugins.springsecurity.SecurityConfigType) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:186) at Config.class$(Config.groovy) at Config.$get$$class$grails$plugins$springsecurity$SecurityConfigType(Config.groovy) at Config.run(Config.groovy:116) 07-Nov-2011 17:40:43 org.apache.catalina.core.StandardContext start SEVERE: Error listenerStart 07-Nov-2011 17:40:43 org.apache.catalina.core.StandardContext start SEVERE: Context [/test] startup failed due to previous errors 07-Nov-2011 17:40:43 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc SEVERE: The web application [/test] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered. 07-Nov-2011 17:40:43 org.apache.catalina.startup.HostConfig deployWAR INFO: Deploying web application archive browser.war 07-Nov-2011 17:40:43 org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory examples 07-Nov-2011 17:40:43 org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory ROOT 07-Nov-2011 17:40:43 org.apache.catalina.startup.HostConfig deployDirectory INFO: Deploying web application directory docs 07-Nov-2011 17:40:43 org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-8080 07-Nov-2011 17:40:43 org.apache.coyote.http11.Http11Protocol start SEVERE: Error starting endpoint java.net.BindException: Address already in use <null>:8080 at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:549) at org.apache.tomcat.util.net.JIoEndpoint.start(JIoEndpoint.java:565) at org.apache.coyote.http11.Http11Protocol.start(Http11Protocol.java:203) at org.apache.catalina.connector.Connector.start(Connector.java:1095) at org.apache.catalina.core.StandardService.start(StandardService.java:540) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) 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:616) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) Caused by: java.net.BindException: Address already in use at java.net.PlainSocketImpl.socketBind(Native Method) at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:336) at java.net.ServerSocket.bind(ServerSocket.java:336) at java.net.ServerSocket.<init>(ServerSocket.java:202) at java.net.ServerSocket.<init>(ServerSocket.java:158) at org.apache.tomcat.util.net.DefaultServerSocketFactory.createSocket(DefaultServerSocketFactory.java:50) at org.apache.tomcat.util.net.JIoEndpoint.init(JIoEndpoint.java:538) ... 12 more 07-Nov-2011 17:40:43 org.apache.catalina.core.StandardService start SEVERE: Failed to start connector [Connector[HTTP/1.1-8080]] LifecycleException: service.getName(): "Catalina"; Protocol handler start failed: java.net.BindException: Address already in use <null>:8080 at org.apache.catalina.connector.Connector.start(Connector.java:1102) at org.apache.catalina.core.StandardService.start(StandardService.java:540) at org.apache.catalina.core.StandardServer.start(StandardServer.java:754) at org.apache.catalina.startup.Catalina.start(Catalina.java:595) 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:616) at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289) at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414) 07-Nov-2011 17:40:43 org.apache.coyote.http11.Http11Protocol start INFO: Starting Coyote HTTP/1.1 on http-8443 07-Nov-2011 17:40:43 org.apache.jk.common.ChannelSocket init INFO: JK: ajp13 listening on /0.0.0.0:8009 07-Nov-2011 17:40:43 org.apache.jk.server.JkMain start INFO: Jk running ID=0 time=0/120 config=null 07-Nov-2011 17:40:43 org.apache.catalina.startup.Catalina start INFO: Server startup in 2286 ms 07-Nov-2011 17:42:14 org.apache.coyote.http11.Http11Protocol pause INFO: Pausing Coyote HTTP/1.1 on http-8080 07-Nov-2011 17:42:14 org.apache.coyote.http11.Http11Protocol pause INFO: Pausing Coyote HTTP/1.1 on http-8080 07-Nov-2011 17:42:14 org.apache.coyote.http11.Http11Protocol pause INFO: Pausing Coyote HTTP/1.1 on http-8443 07-Nov-2011 17:42:15 org.apache.catalina.core.StandardService stop INFO: Stopping service Catalina 07-Nov-2011 17:42:15 org.apache.coyote.http11.Http11Protocol destroy INFO: Stopping Coyote HTTP/1.1 on http-8080 07-Nov-2011 17:42:15 org.apache.coyote.http11.Http11Protocol destroy INFO: Stopping Coyote HTTP/1.1 on http-8080 07-Nov-2011 17:42:15 org.apache.coyote.http11.Http11Protocol destroy INFO: Stopping Coyote HTTP/1.1 on http-8443
I've tried commands such as
netstat -aon | grep 8080
I've triedps -efl | grep java
and killing that process usingkill <pid> 9
pkill java
and so on...This is what
netstat -aon
Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State Timer tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN off (0.00/0/0) tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN off (0.00/0/0) tcp 0 0 10.226.122.156:22 109.58.56.15:49215 ESTABLISHED keepalive (5354.40/0/0) tcp 0 0 :::80 :::* LISTEN off (0.00/0/0) tcp 0 0 :::22 :::* LISTEN off (0.00/0/0) udp 0 0 0.0.0.0:68 0.0.0.0:* off (0.00/0/0) udp 0 0 10.226.122.156:123 0.0.0.0:* off (0.00/0/0) udp 0 0 127.0.0.1:123 0.0.0.0:* off (0.00/0/0) udp 0 0 0.0.0.0:123 0.0.0.0:* off (0.00/0/0) udp 0 0 ::1:123 :::* off (0.00/0/0) udp 0 0 fe80::1031:3cff:fe0:123 :::* off (0.00/0/0) udp 0 0 :::123 :::* off (0.00/0/0) Active UNIX domain sockets (servers and established) Proto RefCnt Flags Type State I-Node Path unix 2 [ ACC ] STREAM LISTENING 2337 @/tmp/fam-root- unix 2 [ ACC ] STREAM LISTENING 409 @/com/ubuntu/upstart unix 2 [ ] DGRAM 644 @/org/kernel/udev/udevd unix 8 [ ] DGRAM 1513 /dev/log unix 3 [ ] STREAM CONNECTED 38302 unix 3 [ ] STREAM CONNECTED 38301 unix 2 [ ] DGRAM 38297 unix 2 [ ] DGRAM 22149 unix 3 [ ] STREAM CONNECTED 2340 @/tmp/fam-root- unix 3 [ ] STREAM CONNECTED 2339 unix 2 [ ] DGRAM 1998 unix 2 [ ] DGRAM 1918 unix 2 [ ] DGRAM 1895 unix 2 [ ] DGRAM 1819 unix 3 [ ] DGRAM 648 unix 3 [ ] DGRAM 647
Any thoughts or pointers?
-
marko over 12 yearsI tried rebooting, the problem did not get solved. I read about this problem, it's like you stated - resources present in the memory. But how do they survive a rebooT?! :S
-
marko over 12 yearsTried changing it to 8181 8383...no effect! This seems like a work around, what I'm looking to do is run on 8080 no matter what. The problem isn't even solved by a reboot!
-
Farhan over 12 yearstry to run ps -aux | grep java, and look for any processes of java running at startup.
-
marko over 12 yearsthanks for the suggestions, I've tried ps -efl | grep java (and other similar combination) noting worked. Eventually I terminated my amazon instance and created a new one...
-
marko over 11 yearsTried that way back when the question was posted, I got the same issue
-
Greg Dougherty over 11 yearsRan ps -aux | grep java. Killed the two instances of Tomcat identified using kill -15. It worked. Thank you!
-
Ashutosh Shukla over 8 yearsThis helped me ,,,Thanks