[Ubuntu]: Can't open any port

October 23, 2014 3.4k views

I followed the following guide:

and tried to open port 80, but I still have nothing open or listening:

netstat -plunt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0*               LISTEN      1051/mysqld     
tcp        0      0    *               LISTEN      965/sshd        
tcp6       0      0 :::22   

The strangest thing is that I could connect to the server yesterday and today it isn't working anymore and the only thing I changed was to add a DNS entry on Digital Ocean.

Could this have anything to do with it?

I tried even to disable any protection with the following commands:

$ sudo iptables -X
$ sudo iptables -t nat -F
$ sudo iptables -t nat -X
$ sudo iptables -t mangle -F
$ sudo iptables -t mangle -X
$ sudo iptables -P INPUT ACCEPT
$ sudo iptables -P FORWARD ACCEPT
$ sudo iptables -P OUTPUT ACCEPT

but still only port 22 is accessible. What could be the reason for this?

  • Why have a firewall in the first place?

    Your running daemons could still get exploited?

    Make sure you know what you have running and on what ports. Secure those daemons which would be much better then implementing a firewall to allow traffic only to certain ports which are in essence the only ports that are actually being used anyway!

  • netstat -plunt will only list ports that something is actively listening on. Do you have a web server listening on port 80? Is Apache or Nginx installed?

1 Answer

netstat -plunt should show you that the web server is trying to listen on port 80 even if it is blocked by the firewall. Make sure the server is running. If it's Apache, run:

service apache2 start

If it's Nginx, then:

service nginx restart
Have another answer? Share your knowledge.