If you are using a standalone instance of Tomcat in your production environment and are facing connectivity issues related to the port, you may need to change the default port of Tomcat. The default port of Tomcat is the standard port on which it listens for incoming requests. These ports are non-standard and are commonly locked by an administrator.

Advertisement

However, if you’ve installed Tomcat as a standalone server and want to change its listening port to a non-standard one, then this article is for you. In this post, we will look at some quick tips on how you can change the default port of Tomcat in a few easy steps. Read ahead to know more!

Changing the Tomcat Port

The first step is to identify the location of the Tomcat installation directory. If you have installed Tomcat from default repositories, it should be installed under the /etc/tomcat{VERSION} directory. For the manual installation, you need to find the correct location.

Then edit server.xml file located under the Tomcat installation directory.

sudo nano /etc/tomcat9/server.xml 

Find the below content in the configuration file

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

Replace port 8080 with your required port. For example, we are changing the default tomcat port to 8081.

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

After making the above changes restart the tomcat service. You will see that now tomcat is started on port 8081 or the port you configured. Access tomcat on the new port in a web browser.

Conclusion

Changing the Tomcat port is helpful and required in many cases, the port is already occupied by another service or you may also run multiple Tomcat versions on a single server. This blog post helps you to change the Tomcat port on your system.

Share.

1 Comment

  1. I have configured tomcat connector on one server and create different virtual host domain but I am facing some issue like I have created vms.dev.com:7070 domain and other is vms.test.com:9090 in tomcat server both domain is accessible in browser but when I open vms.dev.com:9090 it will also open and its directory location is test server and when I open vms.test.com:7070 it will also open and its directory location in dev server. it is possible to restrict port access on other domain in same server like if I want to open vms.dev.com:9090 then it should be give some error. Please help me to solve this issue.

Leave A Reply