Change Tomcat port numbers in server.xml file
- Details
- Written by Nam Ha Minh
- Last Updated on 05 August 2019   |   Print Email
By default, Tomcat is listening on the port number 8080 (for HTTP Connector) and 8009 (for AJP Connector), as shown in the following screenshot of Tomcat’s console when the server is started:
Sometimes, one needs to change these default port numbers because of conflict with other applications or just for convenience, e.g. change HTTP port number from 8080 to 80 in order to type the URL without specifying the number.
It’s very easy to change the port numbers in Tomcat, by doing the following steps:
- Make sure the server is stopped, or shutdown it if it is running.
- Open the server.xml file which can be found under TOMCAT_INSTALL_DIR\conf directory:
- If we want to change the HTTP port number, search for the following lines:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
- Now change the port 8080 to 80:
<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
- Save the server.xml file (make sure you have write permission) and restart Tomcat. Now, we can see the HTTP port number gets changed in the console:
See also: How to change port numbers for Tomcat in Eclipse
Other Tomcat Tutorials:
- How to deploy a Java web application on Tomcat
- How to Embed Tomcat Server into Java Web Applications
- How to Use Virtual Hosts in Tomcat
- Configuring JNDI DataSource for Database Connection Pooling in Tomcat
- How to set web application context path as server root in Tomcat
- How to configure session timeout in Tomcat
- How to add Tomcat server in Eclipse IDE
- How to change server location and deploy path for Tomcat in Eclipse
Comments
Run the text editor with Administrator right. Then use it to edit the server.xml file.