So I made a apache server and put a page up, and it should be accessible on port 80 (so default), and I should be able to curl it.

Apache listens on port 80 (/etc/httpd/conf/httpd.conf)

But when I try to curl it from outside, it gives me a random error:

me@me:~$ curl myaws
curl: (7) Failed to connect to myaws port 80: No route to host

(myaws is my aws instance that has port 80 open, it's an aws ec2 instance).

So this output is from myaws:

[me@here yes]# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0  *               LISTEN      4394/mysqld         
tcp        0      0    *               LISTEN      4580/sshd           
tcp        0      0  *               LISTEN      4538/master         
tcp6       0      0 :::80                   :::*                    LISTEN      10003/httpd         
tcp6       0      0 :::22                   :::*                    LISTEN      4580/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      4538/master         
udp        0      0    *                           3829/dhclient       
udp        0      0 *                           3457/chronyd        
udp6       0      0 ::1:323                 :::*                                3457/chronyd        

But the weird thing is, if I do this following command, then it suddenly accepts my curl:

sudo iptables -I INPUT -p tcp --dport 80 --syn -j ACCEPT

But even after this command, netstat -tulpn gives me the same output.

So I honestly don't understand this... Also this command does not persist, if I do sudo service firewalld restart, then I cannot curl it again until I do the iptables command again...

  • Sorry, I forgot to add that I have the proper security groups, it allows 80 inbound from anywhere. – user361193 Jul 7 at 13:03
  • Also that first link does not tell me what's wrong with it, and why the iptables rule does not show up on netstat -tulpn. Also service iptables save does not work... – user361193 Jul 7 at 13:05
  • @user361193 Why not just open the port via firewall-cmd with firewall-cmd --permanent --zone=public --add-port=80/tcp and then firewall-cmd --reload? If firewalld is running then you don't need to use iptables. After those commands, you can see port 80 open in firewalld with firewall-cmd --list-ports. – Nasir Riley Jul 7 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.