How To Change Tomcat Default Port Configuration?

Tomcat uses by default on port number 8080 on your computer. It is very common that you would have conflict of port number if there is another service running on the same port. You can change the port number for your tomcat server by changing in the configuration file or through the eclipse editor.

1. Update Tomcat Port in Server.xml

You can find the server.xml file under {Tomcat server folder}\conf\. Search for the below entry. The default entry uses the port 8080.

<!-- Define a non-SSL HTTP/1.1 Connector on port 8180 -->
    <Connector port="8080" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />

Change to new port number as follows.

<!-- Define a non-SSL HTTP/1.1 Connector on port 8180 -->
    <Connector port="8081" maxHttpHeaderSize="8192"
               maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
               enableLookups="false" redirectPort="8443" acceptCount="100"
               connectionTimeout="20000" disableUploadTimeout="true" />

Once you re-start the server, it runs on the port 8181.

2. Update Tomcat Port in Eclipse

If you are running the tomcat server embeded with Eclipse IDE, then it is very easy to update the port number without editing the configuration files. You can double click on the server and edit the port number. After the change save the file. It is done.

tomcat-server-1

tomcat-server-2

Comments

comments

About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.

Speak Your Mind

*