• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Can't start Tomcat with port 8080

 
Greenhorn
Posts: 8
Python Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I use the port 8080, Tomcat doesn't start.
However, when I change the port to 8081, it starts.

When I use netstat -abno | find "8080", this is what comes up

C:\Windows\system32>netstat -abno | find "8080"
 TCP    [::1]:8080             [::1]:50529            TIME_WAIT       0


I guess, TIME_WAIT is OK.

Any idea where the problem is ?  

Logs -

21-Jan-2020 12:43:56.921 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version name:   Apache Tomcat/9.0.26
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Sep 16 2019 15:51:39 UTC
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version number: 9.0.26.0
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Windows 10
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            10.0
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             C:\Program Files\Java\jre1.8.0_221
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_221-b11
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         C:\Program Files\Apache Software Foundation\Tomcat 9.0
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         C:\Program Files\Apache Software Foundation\Tomcat 9.0
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=C:\Program Files\Apache Software Foundation\Tomcat 9.0\conf\logging.properties
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=C:\Program Files\Apache Software Foundation\Tomcat 9.0
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 9.0
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 9.0\temp
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.23] using APR version [1.7.0].
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
21-Jan-2020 12:43:56.937 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
21-Jan-2020 12:43:56.952 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.1c  28 May 2019]
21-Jan-2020 12:43:57.421 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
21-Jan-2020 12:43:57.734 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
21-Jan-2020 12:43:57.749 INFO [main] org.apache.catalina.startup.Catalina.load Server initialization in [1,119] milliseconds
21-Jan-2020 12:43:57.796 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
21-Jan-2020 12:43:57.796 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.26]
21-Jan-2020 12:43:57.812 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\docs]
21-Jan-2020 12:43:58.234 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\docs] has finished in [422] ms
21-Jan-2020 12:43:58.234 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\examples]
21-Jan-2020 12:43:58.827 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\examples] has finished in [593] ms
21-Jan-2020 12:43:58.827 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\host-manager]
21-Jan-2020 12:43:58.890 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\host-manager] has finished in [63] ms
21-Jan-2020 12:43:58.890 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\manager]
21-Jan-2020 12:43:58.937 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\manager] has finished in [47] ms
21-Jan-2020 12:43:58.937 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\ROOT]
21-Jan-2020 12:43:58.968 INFO [main] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [C:\Program Files\Apache Software Foundation\Tomcat 9.0\webapps\ROOT] has finished in [31] ms
21-Jan-2020 12:43:58.984 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
21-Jan-2020 12:43:58.984 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
21-Jan-2020 12:43:58.999 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in [1,245] milliseconds
21-Jan-2020 12:43:58.999 SEVERE [main] org.apache.catalina.core.StandardServer.await Failed to create server shutdown socket on address [localhost] and port [8080] (base port [8080] and offset [0])
java.net.BindException: Address already in use: JVM_Bind
at java.net.DualStackPlainSocketImpl.bind0(Native Method)
at java.net.DualStackPlainSocketImpl.socketBind(Unknown Source)
at java.net.AbstractPlainSocketImpl.bind(Unknown Source)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.ServerSocket.bind(Unknown Source)
at java.net.ServerSocket.<init>(Unknown Source)
at org.apache.catalina.core.StandardServer.await(StandardServer.java:584)
at org.apache.catalina.startup.Catalina.await(Catalina.java:721)
at org.apache.catalina.startup.Catalina.start(Catalina.java:667)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:344)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:475)
21-Jan-2020 12:43:58.999 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["http-nio-8080"]
21-Jan-2020 12:43:59.255 INFO [main] org.apache.coyote.AbstractProtocol.pause Pausing ProtocolHandler ["ajp-nio-8009"]
21-Jan-2020 12:43:59.490 INFO [main] org.apache.catalina.core.StandardService.stopInternal Stopping service [Catalina]
21-Jan-2020 12:43:59.521 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["http-nio-8080"]
21-Jan-2020 12:43:59.521 INFO [main] org.apache.coyote.AbstractProtocol.stop Stopping ProtocolHandler ["ajp-nio-8009"]
21-Jan-2020 12:43:59.521 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["http-nio-8080"]
21-Jan-2020 12:43:59.521 INFO [main] org.apache.coyote.AbstractProtocol.destroy Destroying ProtocolHandler ["ajp-nio-8009"]
 
Marshal
Posts: 25682
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The answer is buried in that error log:

java.net.BindException: Address already in use: JVM_Bind



So Tomcat can't start and bind to port 8080 because that port is already in use by some other task. And yes, your netstat shows that there's a task which is using port 8080.

I'm pretty sure that Windows netstat has an option which tells it to output the name of the task which is using the port, but I can't recall it right now. You might want to find out what task is using port 8080 and (maybe) stop it from doing that. Unless it's another version of Tomcat which didn't start properly or didn't stop properly, or something like that. Or if you find it's some other task entirely you'd have to ask whether you need that task or whether it can use some other port... and so on. You should be able to handle that, I think.
 
Chade Fallstar
Greenhorn
Posts: 8
Python Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Paul!
I too suspected what you said.
I checked server.xml

This port was 8080.. earlier
<Server port="8005" shutdown="SHUTDOWN">
 <Listener className="org.apache.catalina.startup.VersionLoggerListener" />

And this one too -

<Connector port="8080" protocol="HTTP/1.1"
              connectionTimeout="20000"
              redirectPort="8443" />

I changed the former to 8005 (default perhaps), and it worked !

 
Saloon Keeper
Posts: 22273
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On Windows you'll often run into this when Tomcat was installed as a Windows Service and is running (even though you weren't aware of it). Starting Tomcat manually will fail, since one and only one process can listen on a port in a given OS instance.

However, port 8080 is also popular for a lot of other applications that present a web interface.

In Linux, "netstat -lnp" will list the process that owns the port. Windows netstat has different options, but you might want to check them.
 
Rancher
Posts: 144
9
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just use "netstat -abno" without the " | find ..." - as windows netstat doesn't list application name in the same line - hence you don't get the name like you want. You just have to look through the output yourself.
 
Chade Fallstar
Greenhorn
Posts: 8
Python Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
WOW! Kristina. That command is really helpful. I output it to a file, and viola, there you get port and info.
I'm complete ignoramus when it comes to windows commandline.

For linux... if the port is known... lsof -i :<port> | grep listen, is the command I think.
Windows services thing is weird. Services start at startup... Once I installed MQ 9. In windows it starts as a service, I think. Hung my system
 
Tim Holloway
Saloon Keeper
Posts: 22273
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Chade Fallstar wrote:
For linux... if the port is known... lsof -i :<port> | grep listen, is the command I think.



Something like that.

But lsof is often not pre-installed on Linux machines and netstat almost always is. So in most cases, I use "netstat -lnp"
 
This one time, at bandcamp, I had relations with a tiny ad.
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic