
Learn through the super-clean Baeldung Pro experience:
>> Membership and Baeldung Pro.
No ads, dark-mode and 6 months free of IntelliJ Idea Ultimate to start with.
Last updated: March 31, 2025
Apache Tomcat (Tomcat for short) is an application that allows us to run Java code on an HTTP web server.
In this tutorial, we’ll learn how to ensure the Tomcat TCP port responds correctly to local and remote user requests.
Firstly, we’ll look at how to check the Tomcat server IP address and the TCP port. Secondly, we’ll find out if there is a firewall rule to make the Tomcat connection available from other machines.
Sometimes, the Tomcat server doesn’t respond because we use the incorrect IP address.
To resolve that, we can utilize the netstat command. It allows us to get the Tomcat IP address and TCP port information:
$ netstat -ltnp | grep java
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 2842/java
tcp 0 0 ::1:8080 :::* LISTEN 2842/java
As can be seen, we have two active Tomcat TCP sockets.
The first one uses the IPv4 address 0.0.0.0 and the TCP port 8080, while the second one has the IPv6 address.
Let’s have a look at the netstat command options in more detail:
Now, we should have enough information to access the Tomcat web page.
Sometimes, there is a problem accessing Tomcat from another Linux machine.
There are a couple of steps we need to follow, to ensure the Tomcat is available remotely.
First, let’s check the Tomcat IP address using the same command as above:
$ netstat -ltnp | grep java
tcp 0 0 10.0.3.1:8080 0.0.0.0:* LISTEN 1626/java
As we can see, the Tomcat remote IP address is 10.0.3.1.
If using this IP address doesn’t help to resolve the problem, then we need to check the firewall setup.
To make Tomcat available from the other machines, our firewall should allow public connections for the TCP port 8080.
For that, we’ll use the ufw (Uncomplicated Firewall).
If the ufw isn’t enabled yet, we enable it:
$ sudo ufw enable
Firewall is active and enabled on system startup
As can be seen, the firewall is now enabled.
Then, we add a rule to make the TCP port 8080 public:
$ sudo ufw allow 8080/tcp
Rule added
Rule added (v6)
The rule has been added.
Let’s double-check that the TCP port 8080 is available with the ufw status command:
$ sudo ufw status
Status: active
To Action From
-- ------ ----
8080/tcp ALLOW IN Anywhere
8080/tcp (v6) ALLOW IN Anywhere (v6)
As we can see, the port 8080 is in the ufw table. Thus, the Tomcat server should now be accessible from the other machines.
In this article, we’ve learned how to fix Tomcat connection problems.
Firstly, we looked at the netstat command to get the Tomcat IP address and the port number. Secondly, we checked how to configure the firewall when trying to access Tomcat from a remote machine.