AntonBoarf
AntonBoarf

Reputation: 1313

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

I'm on Windows10 and downloaded Tomcat 8.5

I go to conf folder and run startup.bat script

After a few seconds, Tomcat stops. And in the logs I can see :

09-Jun-2021 21:52:01.433 INFOS [main] org.apache.coyote.AbstractProtocol.start Démarrage du gestionnaire de protocole ["http-nio-8088"]
09-Jun-2021 21:52:01.484 INFOS [main] org.apache.catalina.startup.Catalina.start Server startup in 748 ms
09-Jun-2021 21:52:01.491 GRAVE [main] org.apache.catalina.core.StandardServer.await StandardServer.await: create[localhost:8005]: 
    java.net.BindException: Address already in use: JVM_Bind
        at java.net.DualStackPlainSocketImpl.bind0(Native Method)
        at java.net.DualStackPlainSocketImpl.socketBind(DualStackPlainSocketImpl.java:102)
        at java.net.AbstractPlainSocketImpl.bind(AbstractPlainSocketImpl.java:513)
        at java.net.PlainSocketImpl.bind(PlainSocketImpl.java:180)
        at java.net.ServerSocket.bind(ServerSocket.java:375)
        at java.net.ServerSocket.<init>(ServerSocket.java:237)
        at org.apache.catalina.core.StandardServer.await(StandardServer.java:421)
        at org.apache.catalina.startup.Catalina.await(Catalina.java:776)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:722)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:342)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:473)

I understand I can change port in server.xml file (which I did). My issue is no matter what port I choose (8081, 8082, 8083 etc...) I ALWAYS got this error :

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

What is wrong ? It's a computer from my company, is there some service, proxy preventing me from running Tomcat ?

The port I choose is free and available. After trying to launch Tomcat with a free port (8087 for example), I got this on command line :

C:\tools\apache-tomcat-8.5.66\bin>netstat -ano | find "8087"
  TCP    [fd5e:b41f:967b:1007:eca0:11ba:a1c9:bbbf]:58009  [fd5e:b41f:967b:1007:eca0:11ba:a1c9:bbbf]:8087  TIME_WAIT       0

Upvotes: 1

Views: 1322

Answers (1)

Piotr P. Karwasz
Piotr P. Karwasz

Reputation: 16045

The failure isn't due by the port on which the HTTP connector listens, but the "shutdown" port (usually 8005), which is already taken.

You configure it using the port attribute of the <Server> element:

<Server port="8005" shutdown="SHUTDOWN">
...
</Server>

In most cases it is safe to disable it setting the value to -1. This will eliminate also a security threat: an attacker can shutdown the server by sending the characters SHUTDOWN to port 8005.

Upvotes: 2

Related Questions