Menu
User

DropVPS Team

Writer: Cooper Reagan

How to open TCP port in Debian 12

How to open TCP port in Debian 12

Publication Date

07/28/2025

Category

Articles

Reading Time

2 Min

Table of Contents

Before starting, make sure you have root or sudo privileges on your Debian 12 system. We’ll walk through the basic steps to open a TCP port using ufw and iptables, depending on which firewall you use.

Step 1: Check if UFW is Installed

UFW (Uncomplicated Firewall) is not enabled by default in Debian. First, check if it’s installed:

sudo ufw status

If you get a “command not found” error, install it with:

sudo apt update
sudo apt install ufw

Step 2: Enable UFW (If Not Already Enabled)

To make sure UFW is active:

sudo ufw enable

This will activate the firewall. Existing connections are not interrupted.

Step 3: Open the Desired TCP Port

For example, to open TCP port 8080, run:

sudo ufw allow 8080/tcp

You can replace 8080 with any port number you need.

To verify:

sudo ufw status numbered

You should see a rule allowing traffic to that port.

Step 4: Using iptables (If Not Using UFW)

If your system doesn’t use UFW and you’re managing firewall rules manually, use iptables.

To open TCP port 8080:

sudo iptables -A INPUT -p tcp --dport 8080 -j ACCEPT

To make it persistent after reboot, install the iptables-persistent package:

sudo apt install iptables-persistent
sudo netfilter-persistent save

Step 5: Check if Port is Open and Listening

After adding the rule, make sure the port is actually open and the service is running on it:

sudo ss -tuln | grep 8080

If nothing shows up, your firewall rule may be fine but no service is using the port yet. And that’s it — your TCP port should now be open on Debian 12.

Linux VPS
U
Loading...

Related Posts