Tomcat – Why Tomcat doesn’t stop

javatomcat

When I run command:

catalina.sh stop

I receive error:

 org.apache.catalina.startup.Catalina stopServer
SEVERE: Catalina.stop:
java.net.ConnectException: Connection refused
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
    at java.net.Socket.connect(Socket.java:529)
    at java.net.Socket.connect(Socket.java:478)
    at java.net.Socket.<init>(Socket.java:375)
    at java.net.Socket.<init>(Socket.java:189)
    at org.apache.catalina.startup.Catalina.stopServer(Catalina.java:456)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.apache.catalina.startup.Bootstrap.stopServer(Bootstrap.java:352)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)

What can be the reason?
Thanks.

Best Answer

Possible reasons

  1. Tomcat is not running. In this case do nothing.
  2. Tomcat go stuck. In this case kill it. I hope it will start working after restart. If not try to check the stdout and error logs. Probably the momory is over or no free space on disk or all filehandlers are used...
  3. There is firewall (?) or some kind of routing problems. It is hard to imagine firewall inside one machine but if for example you have several network cards and tomcat somehow is connected to one of them but the stop utility tries to connect to other it fails.

Probably other reasons are possible. But again, #1 & #2 make more sense.

If problem still exists try to examine logs. If something strange appears in logs but you do not know what to do try to post the logs here.