By default, Tomcat is configured to listen on the following port numbers:

    • Tomcat admin port: 8005
    • HTTP/1.1: 8080
    • AJP/1.3: 8009
Of course, most of the time we are only interested in the HTTP port number - which is the port we have to type in the URL to access a deployed application, for example:

http://localhost:8080/MyCoolApp

Eclipse allows us to change these port numbers easily with just a click of mouse. In the Servers view, double click on the server name:

double click server name

That will open a configuration page for Tomcat as follows:

configuration page for Tomcat in Eclipse

Notice the port numbers are shown in the table on the right. Click to edit, for example:

change HTTP port number for Tomcat

That will change port number for HTTP from 8080 to 80. Press Ctrl + S to save the change and restart the server. We can spot the change of port number in the Console view:



HTTP port number in Console view

Now, with port 80 we can remove the port number in the URL:

http://localhost/MyCoolApp

 

NOTES: Changing the Tomcat’s port numbers in Eclipse does not affect the default Tomcat installation on your computer (outside Eclipse IDE). It is because Eclipse makes a copy of Tomcat configuration in its workspace, by default. If we notice, there is a node called “Servers” in the Project Explorer/Package Explorer view. Expand this node, we will see:

Servers node in Eclipse

Under the hood, Eclipse updates the server.xml file when we make change to the port numbers, just like the way we change Tomcat’s port numbers in general.

Also read: Change Tomcat port numbers in server.xml file

 

You can also follow this video to modify the HTTP port number of 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 

#28Rajamohan Reddy2024-04-23 02:40
starting tomacat 10.1 encounter problem
Quote
#27Angelo2023-06-14 05:23
How do I do this for Tomcat 10
The server still isn't working
Quote
#26rifath2020-09-17 11:30
thank you so much. it worked for me
Quote
#25Jelena2020-02-22 13:51
Thank you! You solved my problem!
Quote
#24dd2019-01-02 06:55
Moin Leude.hihihihihihihiiiiiiiiiiiiiiiiiiiiiiii
Quote