What is Tomcat shutdown port

In default Tomcat installation, you will find the following line at the top of Tomcat‘s global server configuration file server.xml :

This configuration allows remote shutdown of Tomcat by sending telnet command to port 8005. Something to note:

1. Port 8005 is on TCP protocol. This is important for firewall configuration
2. Port 8005 must be available for Tomcat to start. Use “netstate -an | grep 8005 | grep LISTEN” to confirm prior of Tomcat startup
3. The shutdown command is configurable, and case sensitive. In this default configuration (as above), it must be uppercase SHUTDOWN. It can be configured to other value if there is a security concern.

4. If port number is -1, then remote shutdown is disabled

Following steps illustrate how to shutdown Tomcat remotely (I will login directly to Tomcat server and shut it down by telnet)

1. Use telnet client to login to localhost or any Tomcat server. For Windows 7, telnet command is removed, so I used PuTTY. The protocol is set to “Raw” as Tomcat shutdown port 8005 will interpret all characters sent

putty-send-telnet-command-windows2. Once connected, Tomcat gives 10 second to type the shutdown command (SHUTDOWN or other configured shutdown command in server.xml). If no command entered, following error will appear in Tomcat log

3. Entered “SHUTDOWN” in uppercase to shutdown Tomcat immediately, and telnet session will be terminated

4. If lowercase “shutdown” was entered, then the telnet will terminated, while Tomcat will show following message

You can also allow remote Tomcat shutdown by adding hostnames and/or IPs in the CATALINA_HOME/conf/Catalina/localhost/manager.xml file. For example to allow shutdown from 192.168.1.XXX IP range add the following line:

Good luck!