Voiced by Amazon Polly |
Introduction
Apache Tomcat is a workhorse in online development and server management, powering many web services and applications. It is a popular and strong servlet container due to its effectiveness and dependability. However, if you’ve ever used Tomcat, you may have observed that it, by default, uses port 8080. Although completely functional, this isn’t usually the best option for various reasons.
If you want to streamline your URLs, improve user experience, or follow accepted practices, changing Tomcat’s default port to 80 can be a game-changer. This article will give you a step-by-step walkthrough, insightful tips, and best practices for changing Tomcat’s server port from 8080 to 80. let’s dive in and discover how to unleash Tomcat’s potential by making a straightforward yet significant alteration – changing the server port to 80.
Pioneers in Cloud Consulting & Migration Services
- Reduced infrastructural costs
- Accelerated application deployment
Why Change the Port?
- URL Simplification:
URL simplicity is one of the most obvious advantages of switching the Tomcat server port to 80. Tomcat apps can be accessed by default using addresses like http://yourdomain.com:8080/yourapp, where “:8080” is the port number. Your URLs may appear less approachable and more technical as a result.
Your URLs will appear neater and more traditional by moving to port 80, resembling the typical structure for online addresses. Users will use URLs like http://yourdomain.com/yourapp to visit your application, eliminating the port number. This can improve user experience and make the URLs of your web application easier to remember and access.
- Conventional Port usage:
The World Wide Web’s primary protocol, HTTP, uses port 80 by default. It is assumed that you are connected to port 80 on the web server when you type “http://www.example.com” into your browser to access a website. Your web application will adhere to this generally accepted practice if Tomcat’s port is changed to 80. Using port 80, you can signal to consumers and web browsers that your application uses conventional HTTP and well-known websites and services. Your users and your application’s reputation may benefit from the professionalism and adherence to web standards that this can lend.
- Improved User Experience:
Any online application’s success depends heavily on the user experience. An improved user experience is achieved by streamlining URLs and using standard ports. Users find URLs without port numbers more understandable, lowering the likelihood of confusion. Finally, switching from port 8080 to port 80 of the Tomcat server has many benefits. It improves user experience, harmonizes with traditional port usage, and simplifies URLs. These advantages make it a valuable modification for any web developer or administrator trying to maximize the professionalism and accessibility of their web application.
Prerequisites
Before switching Tomcat’s server port from 8080 to 80, it’s crucial to ensure you have the following conditions met. These conditions must be met for a seamless and trouble-free changeover.
- Administrative Access to Tomcat Configuration
- Back Up Your Existing Configuration
Steps to Change Port
Let’s start with the actual procedures to accomplish this port change now that we’ve established the benefits of switching the Tomcat server port to 80 and verified that we meet the requirements.
Note: we are using Ubuntu 20.04 for this demonstration.
- Stop Tomcat:
The Tomcat server must be stopped gracefully before any configuration changes can be made. By doing this, the port change procedure ensures no running connections or processes are interrupted. To stop Tomcat:
- Open the terminal or command prompt.
- Execute the following command to stop Tomcat:
1 |
Sudo systemctl stop tomcat |
If you’re on Windows, use shutdown.bat instead.
You can change the status of Tomcat using the command “sudo systemctl status tomcat”
2. Locate server.xml:
Next, look for the server.xml configuration file within your Tomcat installation. The configuration for the HTTP connector, which defines the port, is included in this file’s list of options for the Tomcat server. Tomcat is installed in a directory like /opt/tomcat or /usr/local/tomcat, so you might use a command like this (replace /path/to/tomcat with your actual Tomcat installation path). Access to this file is possible through command-line tools or a text editor.
1 2 3 |
Sudo su - Cd /path/to/tomcat/conf Sudo vi server.xml |
- Edit server.xml:
With the server.xml file open, look for the <Connector> element that specifies the HTTP connector settings. It will typically look something like this:
1 |
<Connector port="8080" protocol="HTTP/1.1" ... /> |
Change the port attribute from 8080 to 80 as follows:
1 |
<Connector port="80" protocol="HTTP/1.1" ... /> |
Make sure to save the file after making this change.
- Edit startp.sh:
Now locate and edit the startup.sh it should be in the bin folder of your tomcat installation directory. In startup.sh look for <exec> element, it will look like this:
1 |
exec "$PRGDIR"/"$EXECUTABLE" start "$@" |
You need to edit this by adding authbind –deep as follows:
1 |
exec authbind --deep "$PRGDIR"/"$EXECUTABLE" start "$@" |
- Install authbind:
You need to install authbind if it is not present in your system. You can do that by executing the following command
1 |
Sudo apt-get install authbind |
- Make port 80 available to authbind:
You need to be in root to do this. Run the following commands to make port 80 available to authbind.
1 2 3 |
Sudo touch /etc/authbind/byport/80 sudo chmod 500 /etc/authbind/byport/80 sudo chown tomcat /etc/authbind/byport/80 |
- Restart tomcat:
Now, we have met all the requirements to change the port from 8080 to 80, and we must restart the Tomcat server.
- Return to the terminal or command prompt.
- Navigate to your Tomcat installation directory.
- Execute the following command to start Tomcat:
1 |
./bin/startup.sh |
If you’re on Windows, use startup.bat instead.
You can also do this by using the following command in Linux:
1 |
Sudo systemctl restart tomcat |
With the modified port setting, Tomcat will now launch. The new URL, which no longer contains:8080 in the address to access your web application, will allow you to confirm that the port change was successful.
Conclusion
However, it’s important to be vigilant while implementing security precautions and recommended practices. Changing the port improves your application’s overall quality and usability while simplifying access to it. Accept this modest but significant change as you go towards web excellence.
Drop a query if you have any questions regarding Apache Tomcat and we will get back to you quickly
Making IT Networks Enterprise-ready – Cloud Management Services
- Accelerated cloud migration
- End-to-end view of the cloud environment
About CloudThat
CloudThat is an award-winning company and the first in India to offer cloud training and consulting services worldwide. As a Microsoft Solutions Partner, AWS Advanced Tier Training Partner, and Google Cloud Platform Partner, CloudThat has empowered over 850,000 professionals through 600+ cloud certifications winning global recognition for its training excellence including 20 MCT Trainers in Microsoft’s Global Top 100 and an impressive 12 awards in the last 8 years. CloudThat specializes in Cloud Migration, Data Platforms, DevOps, IoT, and cutting-edge technologies like Gen AI & AI/ML. It has delivered over 500 consulting projects for 250+ organizations in 30+ countries as it continues to empower professionals and enterprises to thrive in the digital-first world.
FAQs
1. Can I choose any port number I want, or are there restrictions?
ANS: – Tomcat can use any open port, but it’s important to consider potential conflicts and security ramifications. Ports below 1024 are frequently set aside for well-known services and can only be used with administrative rights.
2. What are the security risks associated with using port 80 for Tomcat?
ANS: – Port 80 is connected to common HTTP traffic. Therefore, utilizing Tomcat directly on it could put your server at risk for security issues. Running Tomcat behind a reverse proxy server, such as Apache or Nginx, can help to minimize this by adding an extra layer of security and enabling SSL/TLS encryption.

WRITTEN BY Shakti Singh Chouhan
Shakti Singh is a Research Associate (Infra, Migration, and Security) at CloudThat. He is a passionate learner committed to learning new things every day. Shakti enjoys sharing his knowledge with others. He likes singing and listening to music in his leisure time.
Comments