69

I have installed and web application which is running on port 8080 on RHEL (centOS). I only have command line access to that machine. I have tried to access that application from my windows machine from which I am connected to server via command-line, but it is giving connection time out error.

Then I have tried to open port 8080. I have added following entry into the iptables.

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

After adding this into the iptables I have restarted it with - /etc/init.d/iptables restart

But still I am not able to access that application from my windows machine.

Am I doing any mistake or missing something?

3
  • Have you disabled selinux? which version of centos are you running? Sep 26, 2013 at 17:21
  • 1
    is there any other firewall between? you sure you're app is listening? Make sure you see something when you do netstat -an | grep 8080
    – Joe T
    Sep 26, 2013 at 17:21
  • I have the same issue on CentOS v7 Netstat shows nothing for 8080 so do the iptables line then check again still nothing being trying to do this for weeks does anyone now how to actually add 8080 so it is accessable from outside
    – AndrewT
    Sep 5, 2017 at 8:40

2 Answers 2

99

The following configs works on Cent OS 6 or earlier

As stated above first have to disable selinux.

Step 1 nano /etc/sysconfig/selinux

Make sure the file has this configurations

SELINUX=disabled

SELINUXTYPE=targeted

Then restart the system

Step 2

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

Step 3

sudo service iptables save

For Cent OS 7

step 1

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

Step 2

firewall-cmd --reload
3
  • 7
    Step 3 fails save is not a valid parameter
    – AndrewT
    Sep 5, 2017 at 8:42
  • 1
    Did you see it's for CentOS 6 or earlier? Works for me. Mar 24, 2020 at 13:30
  • Bad argument 'NEW'
    – manudicri
    Jan 13, 2021 at 15:09
49

First, you should disable selinux, edit file /etc/sysconfig/selinux so it looks like this:

SELINUX=disabled
SELINUXTYPE=targeted

Save file and restart system.

Then you can add the new rule to iptables:

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

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

If it doesn't work you should check other network settings.

6
  • 1
    selinux is disable and selinuxtype is set to targeted and append rule to the iptables. Restarted the iptables as well but still not working. Need to check other network configuration Sep 26, 2013 at 18:16
  • @jabaldonedo I get a 9001 socket exception at exactly 2 hours of a mongodb load from a centos server. Could this be a solution to that? If so, in your opinion, do i have to do this on both the remote host and the requesting host or just the remote host? Thanks!
    – kmehta
    Oct 8, 2013 at 15:15
  • Maybe your problem is not related with CentOS, are you sure that your application is correctly configured? that error is a connection issue from MongoDB. I don't know what application are you trying to run, but I suggest you to check again its configuration and/or if you can, ask for some support help. Oct 8, 2013 at 15:23
  • Yeah it's a mongodb client method "db.cloneCollection". I haven't found any sort of timeout configuration either on the mongo client or the mongod server process.
    – kmehta
    Oct 8, 2013 at 16:37
  • Restarting iptables flused my new rule
    – blackbird
    Jan 7, 2016 at 18:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.