Coder Perfect

[closed] How to open a port in Linux


On RHEL, I’ve installed a web application that runs on port 8080. (centOS). On that machine, I only have access to the command line. I attempted to access that application from my Windows machine, which is connected to the server through command-line, but the connection timed out.

After that, I attempted to open port 8080. In iptables, I’ve inserted the following entry.

I restarted iptables after adding this to the file – /etc/init.d/iptables restart

However, I am still unable to use that application on my Windows system.

Is there something I’m missing or am I making a mistake?

Asked by Niraj Chapla

Solution #1

The following configurations are compatible with CentOS 6 and prior.

As previously explained, you must first disable selinux.

/etc/sysconfig/selinux/nano /etc/sysconfig/selinux/nano /etc/s

Ascertain that the file contains the following settings.



Then reboot the computer.

Step 2

iptables -A INPUT -m state --state NEW -p tcp --dport 8080 -j ACCEPT

Step 3

sudo service iptables save

CentOS 7 is supported.

step 1

firewall-cmd --zone=public --permanent --add-port=8080/tcp

Step 2

firewall-cmd --reload

Answered by Nirojan Selvanathan

Solution #2

First, disable selinux by editing the file /etc/sysconfig/selinux as follows:


Save the file and restart the computer.

Then, in iptables, add the new rule:

iptables -A INPUT -m state --state NEW -p tcp --dport 8080 -j ACCEPT

and /etc/init.d/iptables restart to restart iptables

If it still doesn’t work, check your network settings.

Answered by jabaldonedo

Post is based on