In Tomcat, all configuration information are maintained in file server.xml
, the default tomcat port number is 8080. However the default port might conflict with other programs when starting up tomcat, in such case, you could meet the error ‘the tomcat server port 8080 is already in use’. The follow steps demonstrate how to change tomcat default port.
How to change the tomcat default port:
(1) Go to the tomcat installation directory {Tomcat installation folder}\conf\
, open server.xml
and find the below:
<!-- Define a non-SSL HTTP/1.1 Connector on port 8080 --> <Connector port="8080" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" /> <!-- Note : To disable connection timeouts, set connectionTimeout value to 0 -->
The statement port="8080"
defines a tomcat non-SSL HTTP connection port 8080. you can change it to any other port number. In the following example, the port has been changed to 8085, save this file and restart tomcat, the tomcat server will run on the new port 8085.
<Connector port="8085" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" />
If you want to change tomcat HTTPS port number, see the following example.
<!-- Define a SSL HTTP/1.1 Connector on port 8443 --> <Connector port="8443" maxHttpHeaderSize="8192" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" disableUploadTimeout="true" acceptCount="100" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" />