Tomcat Not Responding After Port Change: Fix
If you changed the port in Tomcat’s server.xml and the server now won’t start or respond, the fix is almost always one of three things: correcting the connector port syntax, checking for a port conflict, or updating the firewall and client URL. Below is a step-by-step guide to diagnose and resolve each cause.
Why Tomcat Stops Responding After a Port Change
Tomcat reads its network configuration from conf/server.xml. The relevant line is the <Connector> element, typically with port="8080". When you change that number, several things can go wrong:
- Syntax error – a missing quote, an extra character, or a duplicate connector.
- Port already in use – another process (including another Tomcat instance) is listening on the new port.
- Firewall blocking – the OS firewall or security group still allows only the old port.
- Client still using the old URL – you may have forgotten to include the new port in the browser or application.
- Tomcat failed to start – if the server didn’t boot, it won’t respond on any port.
Step 1: Verify the server.xml Syntax
Open conf/server.xml in a text editor and locate the Connector line. It should look like this:
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
Change the port value to your desired number, e.g., port="9090". Ensure you keep the double quotes and don’t accidentally delete the closing />. If you added a second Connector line, remove the old one—having two connectors on the same port will cause a bind error.
Step 2: Check for Port Conflicts
If Tomcat starts but immediately stops, or if you see a BindException in logs/catalina.out, the port is likely taken. On Linux/macOS, run:
sudo lsof -i :9090
On Windows, use:
netstat -ano | findstr :9090
If you see a process listening, you have two options: stop that process or choose a different port. Also, remember that the default HTTPS connector uses port 8443; if you changed that too, check both.
Step 3: Restart Tomcat Properly
After editing server.xml, you must restart Tomcat. A simple shutdown.sh (or shutdown.bat) followed by startup.sh is usually enough. But if Tomcat didn’t shut down cleanly, the old process may still hold the old port. Force-kill it:
pkill -f catalina
Then start Tomcat again. Check the logs for any errors.
Step 4: Update Firewall Rules
If Tomcat is running but you can’t access it from another machine, the firewall is the likely culprit. On Linux with ufw, allow the new port:
sudo ufw allow 9090/tcp
On CentOS/RHEL with firewalld:
sudo firewall-cmd --permanent --add-port=9090/tcp sudo firewall-cmd --reload
On Windows, open Windows Defender Firewall and add an inbound rule for the new port. Don’t forget to also update your cloud security group if you’re using AWS, Azure, or similar.
Step 5: Update Client URLs
Your browser or application must use the new port. For example, if you changed to 9090, the URL becomes http://localhost:9090. If you have a reverse proxy (like Nginx) in front of Tomcat, update its proxy_pass directive to point to the new port.
Common Mistakes and Misconceptions
- Changing the wrong file – Some users edit
conf/server.xmlbut Tomcat is actually using a different configuration file (e.g., if you have a custom CATALINA_BASE). Verify withecho $CATALINA_BASE. - Port 8080 vs 80 – Port 80 requires root privileges on Linux. If you try to run Tomcat on port 80 as a non-root user, it will fail. Use a high port (above 1024) or set up a reverse proxy.
- Environment variables – Some deployment scripts override the port via environment variables like
SERVER_PORT. Check your startup scripts. - Tomcat not responding vs not starting – If the process is running but you get a connection refused, it’s a firewall or URL issue. If the process isn’t running, check logs.
Frequently Asked Questions
How do I change the port in Tomcat 9 or 10?
The process is identical: edit conf/server.xml, change the port attribute on the HTTP Connector, and restart. Tomcat 9 and 10 use the same configuration format.
Why does Tomcat say “Port already in use� even after I changed it?
This usually means the old Tomcat process is still running. Kill it with pkill -f catalina (Linux) or taskkill /F /PID <pid> (Windows), then start again. Also check that no other service (like Apache or another Java app) is using the new port.
Can I use port 80 without being root?
On Linux, binding to ports below 1024 requires root privileges. You can use authbind or set up a reverse proxy like Nginx to forward port 80 to Tomcat’s port (e.g., 8080).
What if I changed the port but Tomcat still responds on the old one?
This suggests Tomcat didn’t actually reload the configuration. Ensure you restarted the server, not just reloaded the web app. Also check if there are multiple Tomcat instances running.
How do I check if Tomcat is listening on the new port?
Use netstat -tulpn | grep 9090 on Linux or netstat -ano | findstr 9090 on Windows. If you see java listening, Tomcat is up. Then try curl http://localhost:9090 to see if it responds.
Why does changing the port break my HTTPS connector?
The HTTPS connector has its own port attribute (default 8443). If you changed the HTTP port but not the redirectPort in the HTTP connector, the redirect may go to the wrong port. Update the redirectPort to match your HTTPS connector’s port.
Related
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.