Bobcares

Different methods to open port 8080 in Debian

by | Apr 26, 2019

Some services like Tomcat accept connections on port 8080.

However, this port is not open by default in Debian Linux servers and can cause the service to fail during setup.

Today, we’ll look at how our Support Engineers configure Debian to accept connections in port 8080.

 

Different methods to open port 8080 in Debian

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 the web address uses port 8080, it requires a default port to override and connect instead of port 80, i.e., 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.

An Overview:

How do I find out if port 8080 is open?

To verify that port 8080 is open and listening, we can use the netstat or ss commands:

netstat -lntu | grep :8080

or

ss -lntu | grep :8080

 

If these commands return output indicating that port 8080 is in a listening state, it confirms that the port is successfully opened.

 

The flags used here are:

  • -l: Show only listening sockets.
  • -n: Show numerical addresses instead of resolving hostnames.
  • -t: Show TCP sockets.
  • -u: Show UDP sockets.

 

Methods to open port 8080 in Debian

There are different methods to open ports in Debian.

Now, let’s see each one of them listed below.

1. Using iptables

From our experience managing servers, we see that iptables are one of the most common ways to open ports in Debian. This requires certain rules to allow and block traffic in iptables. Any wrong command can result in the server being unreachable.

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 to us a problem with adding port 8080 in apache2 where his OS is Debian 4.1.2-25.

So, to fix the problem, we opened the apache2/ports.conf file and added the following lines.

NameVirtualHost *:8080
Listen 8080

Also, in the apache2/sites-available/default file, I added the below line.

<VirtualHost *:8080>

Then, restart the apache2 service and verify if the port is open 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 more easily.

With UFW, we execute steps like this for an application like Tomcat to open port 8080.

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; we 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 command below.

firewall-cmd --list-ports

 

5. Using nftables

nftables is a modern replacement for iptables and is used to manage network traffic filtering. If our Debian system uses nftables, we can open port 8080 with the following commands:

  • Check if nftables is active:

    sudo systemctl status nftables

  • Open port 8080:

    We can add a rule to allow traffic on port 8080 by creating or modifying a ruleset. Here’s how to do it:sudo nft add rule ip filter input tcp dport 8080 accept

    To ensure the rules persist after a reboot, save them using:
    sudo nft list ruleset > /etc/nftables.conf

  • Reload nftables:

    If we’ve made changes to the configuration file, reload it with:sudo nft -f /etc/nftables.conf

6. Modifying /etc/services

While this method does not directly open port 8080, it is useful for ensuring that applications recognize the port correctly. We can add an entry for port 8080 in the /etc/services file, which maps service names to ports.

  1. First, open the file with your preferred text editor.

    sudo nano /etc/services

  2. At the end of the file, add a line like this:

    myservice 8080/tcp # My custom service on port 8080

  3. After adding the line, save the changes and exit the editor.

[Having trouble with Debian open port 8080? We’ll fix it for you.]

 

Conclusion

To open port 8080 in Debian, we can use methods like iptables, ufw, firewalld, etc. Today, we saw how our Support Engineers opened “Debian open port 8080”.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.