2

I have configured in server.xml to listen port 8005 for shutdown, but always receive connection refused error. Also checking by telnet/netstat shows that nothing listens on port 8005. Does exists another configuration/policy setting that should be done for graceful shutdown of tomcat? Thanks.

user710818
  • 23,228
  • 58
  • 149
  • 207

3 Answers3

3

Unless you post a snippet of your server.xml where you configure tomcat, tell us its version and provide the startup log and script, there is no way we can help you better.

Take a look at this post, from your post I understand you can't telnet to 8005 but maybe you missed something, maybe some program is occupying some of the ports occupied by tomcat? Check your server logs and find the reason why it doesn't want to connect. If it is simply connection refused, you have a port/firewall issue.

Several ports (8005, 8080, 8009) required by Tomcat Server at localhost are already in use

P.S If everything is left to the standard configuration, then your tomcat server should start listening for shutdown to port 8005. If you check the server log, when you shutdown, you should have something like this(tomcat 7.23):

Dec 28, 2011 4:01:22 PM org.apache.catalina.core.StandardServer await INFO: A valid shutdown command was received via the shutdown port. Stopping the Server instance.

Also, another things to note:

  1. Do you start your tomcat as root (I assume you are using some non Windows OS)?

  2. Do you use a Security Provider?

  3. From your post I could not understand if your server starts at all. If you had provided a part of the logs, maybe we could have helped you better.

    Last steps to check is to disable your firewall/iptables or whatever might be preventing you from opening a port. Check what will happen if you set the port to a number higher than 32000, some security settings might be preventing you to open a lower number port.

EDIT: To further add, live non-daemon threads that are still busy may prevent the server from gracefully shutting down if you don't implement their shutdown hooks, but as your server doesn't want to even bind on 8005 and you get a 'connection refused' error, I believe it is a firewall/port/permission issue. I can only suggest you run it as root/admin or whatever and try the embedded tomcat that comes with a Netbeans installation. Also, check if your tomcat starts with some weird flags, with a Security Manager in place, or with a permissions file that could be restricting your jvm. Also, if you are using Windows and your tomcat is in Program files or you start it as a service, you might get some weird behaviour, start it from command line. Also, try a newer tomcat, also try a newer jvm, also try an out-of-the box tomcat, you can download it from the official site.

EDIT, EDIT:

Probably for security considerations you are not allowed to paste the logs, but in troubleshooting the problem it would really help to see the part where it tries to bind on 8005 and fails.

Community
  • 1
  • 1
Nikola Yovchev
  • 9,498
  • 4
  • 46
  • 72
  • standard files of Tomcat. I didn't changed them. – user710818 Dec 28 '11 at 10:40
  • version as well, jdk version, etc... :) – Nikola Yovchev Dec 28 '11 at 14:52
  • Tomcat is running, I can see with ps aux | grep tomcat. Can it be related that I have different catalina_base and catalina_home? – user710818 Dec 28 '11 at 17:23
  • Did you try disabling firewall and /or iptables? Does it start binding to localhost or to some ip? Post the logs and /or server.xml so we can see if you have a bad config. If nothing works, I can suggest you download a netbeans with an embedded tomcat, run it as root and start the tomcat from inside: http://netbeans.org/downloads/start.html?platform=linux&lang=en&option=all – Nikola Yovchev Dec 28 '11 at 18:35
  • It is hosted environment. I cannot change tomcat installation, but if I found error in configuration - host provider will fix. But for moment I don't know what to do. – user710818 Dec 28 '11 at 18:40
  • oh, it is a hosted environment. I myself manage some on a hosted environment. Maybe it runs in a VM with restrictions on opening LISTEN on ports? Does it bind to the other ports, like HTTP/APR/AJP ? – Nikola Yovchev Dec 28 '11 at 18:46
  • I cannot figure out in which moment catalina.out pass shutdown port to bootstrap class. I think the problem that for some misconfiguration catalina does not read correct shutdown port. – user710818 Dec 28 '11 at 18:49
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/6204/discussion-between-baba-and-user710818) – Nikola Yovchev Dec 28 '11 at 18:49
2

It is stored in server.xml:

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

AlexR
  • 114,158
  • 16
  • 130
  • 208
0

This is probably the case where you have set the -server in your JAVA_OPTS. This is keeping the server from starting listening on port 8005. I am trying to track down why this is happening and ran across your question.

  JAVA_OPTS="-Dfile.encoding=UTF-8 \
  -Dcatalina.logbase=/var/log/tomcat8 \
  -XX:+DoEscapeAnalysis \
  -XX:+UseConcMarkSweepGC \
  -XX:+CMSClassUnloadingEnabled \
  -XX:+UseParNewGC \
  -Xms3G -Xmx3G" \
  -server
Chris Hinshaw
  • 6,967
  • 2
  • 39
  • 65