How to Change Tomcat Port Number?

Here you learn how to change tomcat port number.

The default port number of tomcat is 8080. If the port number assigned to tomcat is used by any other application then you can’t run tomcat on that port. In that situation the only solution is to change tomcat default port number. There are two ways to achieve this that I have mentioned below.

How to Change Tomcat Port Number?

 

Method 1: Tomcat Installation Directory

1. Go to conf folder in tomcat installation directory. Most probably you can find it inside C:/Program Files/Apache Software Foundation/Tomcat/conf

2. Now open server.xml with any text editor like notepad.

How to Change Tomcat Port Number 1

3. Look for following lines inside the file.

How to Change Tomcat Port Number 2

4. Change the port number inside Connector port=”8080″ to whatever value you want and then save the file.

5. Now tomcat will run on new port number.

Note: Sometimes you might get Access Denied error when you will save the server.xml file after editing. In that case just cut the file from conf folder and paste it somewhere else like desktop or any other directory. Now edit and save the file and paste it back in conf folder in tomcat installation directory.

Method 2: Eclipse IDE

You can try this method if you are using tomcat in eclipse ide.

1. Open Eclipse and go to Console. There click on Servers tab as shown in below image.

How to Change Tomcat Port Number 3

2. There double click on Tomcat server. A window will open as shown below.

How to Change Tomcat Port Number 4

3. At right side under Ports section all ports are shown. Change the value of HTTP/1.1 to whatever port you want.

4. Finally press ctrl + s to save the settings. You have done!

Note: Changing the port number in eclipse will not affect in tomcat installation directory. Because eclipse keeps separate copy of tomcat configuration in workspace.

Comment below if you are facing any difficulty to change tomcat port number.

Leave a Reply

Your email address will not be published. Required fields are marked *