95

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?

Zam
  • 2,709
  • 1
  • 15
  • 31
Siva Siva
  • 999
  • 1
  • 6
  • 5

4 Answers4

196

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!.

Chaminda Bandara
  • 1,635
  • 2
  • 23
  • 29
kark
  • 4,363
  • 6
  • 28
  • 43
  • 2
    In windows usually, the tomcat config folder is located at "C:\Program Files\Apache Software Foundation\Tomcat 9.0\conf" – Marwan Salim Nov 06 '18 at 04:48
  • If I change to 8081, it works perfectly, but if i change to 80, it did not work at all. Googled a few solutions, no one worked, any idea? I am using Apache 9 & Ubuntu 18. Thanks – Charlie Dec 26 '19 at 01:20
22

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

Prabhakaran Ramaswamy
  • 23,910
  • 10
  • 51
  • 62
5

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.

Juned Ahsan
  • 63,914
  • 9
  • 87
  • 123
5

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/

Deepika C P
  • 1,117
  • 2
  • 12
  • 23