How to change Apache Tomcat web server port number

TomcatPort

Tomcat Problem Overview


How to change Apache Tomcat web server default port number?


I am developing a web application in JSP, in that for some purpose I need to change tomcat accessing port. Is there any possibility?

Tomcat Solutions


Solution 1 - Tomcat

Simple !!... you can do it easily via server.xml

  • Go to tomcat>conf folder
  • Edit server.xml
  • Search "Connector port"
  • Replace "8080" by your port number
  • Restart tomcat server.

You are done!.

Solution 2 - Tomcat

Navigate to /tomcat-root/conf folder. Within you will find the server.xml file.

Open the server.xml in your preferred editor. Search the below similar statement (not exactly same as below will differ)

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

Going to give the port number to 9090

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

Save the file and restart the server. Now the tomcat will listen at port 9090

Solution 3 - Tomcat

You need to edit the Tomcat/conf/server.xml and change the connector port. The connector setting should look something like this:

<Connector port="8080" maxHttpHeaderSize="8192"
           maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
           enableLookups="false" redirectPort="8443" acceptCount="100"
           connectionTimeout="20000" disableUploadTimeout="true" />

Just change the connector port from default 8080 to another valid port number.

Solution 4 - Tomcat

  1. Locate server.xml in {Tomcat installation folder}\ conf \

  2. Find following similar statement

        <!-- 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" />
    

For example

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

Edit and save the server.xml file. Restart Tomcat. Done

Further reference: http://www.mkyong.com/tomcat/how-to-change-tomcat-default-port/

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSiva SivaView Question on Stackoverflow
Solution 1 - TomcatkarkView Answer on Stackoverflow
Solution 2 - TomcatPrabhakaran RamaswamyView Answer on Stackoverflow
Solution 3 - TomcatJuned AhsanView Answer on Stackoverflow
Solution 4 - TomcatDeepika C PView Answer on Stackoverflow