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:

Tomcat start logs

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:Locate server.xml file

    • 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:Tomcat HTTP port changed

See also: How to change port numbers for Tomcat in Eclipse



 

Other Tomcat Tutorials:


About the Author:

is certified Java programmer (SCJP and SCWCD). He began programming with Java back in the days of Java 1.4 and has been passionate about it ever since. You can connect with him on Facebook and watch his Java videos on YouTube.



Add comment

   


Comments 

#3Nam2019-06-28 03:40
Quoting fadi halim:
how to get the permission for cahnging the port number

Run the text editor with Administrator right. Then use it to edit the server.xml file.
Quote
#2fadi halim2019-06-27 04:42
how to get the permission for cahnging the port number
Quote
#1gowtami2017-01-24 17:22
Thanks for the inputs
Quote