Some services like Tomcat accepts connections on port 8080.
But this port is not open by default in Debian Linux servers and can cause the service to fail during setup.
Today, we’ll take a look at how our Support Engineers configure Debian to accept connections in port 8080.
What is port 8080 used for?
Port 8080 is an alternative to port 80 and is commonly used as a proxy and caching port. It is also above the well-known service port range (1-1023).
For example, applications like Apache Tomcat, M2MLogger, and a Web GUI use port 8080 to connect to internet services.
If web address uses port 8080, it require a default port to override and connect instead of the port 80 ie., the user has to type http://localhost:8080/web.
Where,
- localhost ( hostname ) is the machine name or IP address of the host server e.g Glassfish, Tomcat.
- 8080 ( port ) is the address of the port on which the host server is listening for requests.
- web – path pointing to the root of the public folder of your server.
How do I find out my port 8080 is opened?
It is simple, you can use netstat command to see if port 8080 is opened.
netstat -aon | findstr "8080"
This command displays all connection, process Id and listening port.
Now, let’s take a look at the different methods and how we open port 8080 in Debian.
Methods to open port 8080 in Debian
There are different methods to open port in Debian.
Now, let’s see each one of them listed below.
1. Using iptables
From our experience in managing servers, we see that iptables is one of the most common ways to open port in Debian. This requires certain rules to allow and block traffic in iptables. Any wrong command can result in server unreachable.
That’s why, our Support Engineers always double check the iptables rules before saving them. And, the iptables command to open port 8080 is,
iptables -I INPUT 1 -i eth0 -p tcp --dport 8080 -j ACCEPT
service iptables save
service iptables restart
To list which ports are opened run the below command
iptables -L
2. Adding port in apache2
Recently one of our customers reported us with a problem to add port 8080 in apache2 where his OS is Debian 4.1.2-25.
So, to fix the problem we opened apache2/ports.conf file and added the following lines.
NameVirtualHost *:8080
Listen 8080
And also in apache2/sites-available/default file added the below line.
Then, restarted apache2 service and verified if the port is opened by running the command
netstat -ntlp
3. Using UFW
Similarly, another option to open port 8080 is using UFW (Uncomplicated Firewall).
This is a user-friendly front-end for managing iptables firewall rules easier.
With UFW for an application like Tomcat to open port 8080, we execute the steps like this.
ufw allow 8080/tcp
ufw status
The output will look like this.
Status: active
To Action From
-- ------ ----
[ 1] 22/tcp ALLOW IN Anywhere
[ 2] 80/tcp ALLOW IN Anywhere
[ 3] 8080/tcp ALLOW IN Anywhere
4. Using FirewallD
In addition, FirewallD is a default firewall management tool that manages the system’s iptables rules.
Opening a port 8080 in firewalld is fairly simple, you need to run the command and reload the service as shown below.
firewall-cmd --prmanent --add-port=8080/tcp
firewall-cmd --reload
To list the ports that are opened run the below command.
firewall-cmd --list-ports
[Having trouble with Debian open port 8080? We’ll fix it for you.]
Conclusion
To open port 8080 in Debian, we can use any methods like iptables, ufw, firewalld, etc. Today, we saw how our Support Engineers opened “Debian open port 8080”.