Port 80 failed: Connection refused

January 26, 2017 16.4k views
Firewall Ubuntu

Suddenly my server down !, and when tried
curl http://myip -v

* Rebuilt URL to: http://myip/
*   Trying myip...
* connect to myip port 80 failed: Connection refused
* Failed to connect to myip port 80: Connection refused
* Closing connection 0
curl: (7) Failed to connect to myip port 80: Connection refused

How detect the reason ? which log file can i see it ?

Please help.

11 Answers

Use SSH to check syslog and your webserver logs.

  • I did but i can`t detect the reason !

    • Is your webserver running?

      • my@server:~$ service nginx status
        nginx stop/waiting
        
        

        What is this mean ?

        • I cannot tell you everything. Please use Google, read some guides or hire a sysadmin.

          • @Woet

            That's really not all that helpful. The community exists to provide a means to help those who need it. Referring them to Google, another SE, or telling them to hire a sysadmin doesn't provide a solution to their immediate issue.

            I'd of already replied with a solution, though it seems that there's an issue within the community that is preventing me from doing so.

          • Thanks for your opinion, but I'd rather teach people how to learn than spoon-feed.

          • @Woet

            I understand, though the community exists for a reason. Anyone can do a quick search on Google, Bing, or another SE just as anyone can click the link at the top of the page labeled "Tutorials" and search the existing database of guides offered by DigitalOcean. They post here because they need as quick an answer as they can get, not to be told to look elsewhere.

            What applies today may not apply tomorrow. That's the case quite often even with DigitalOcean's very own guides -- they need to be updated frequently. When it comes to searching, not everyone is a sysadmin and due to that fact, so they may not know what to search for.

            If you look at guides outside of DigitalOcean, not many are maintained and if they are, they aren't always maintained to the fullest extent.

            That said, I don't consider it to be spoon-feeding any more than a tutorial or guide. Whether a solution is posted here or a link is provided with what I would have typed out, someone spends the time to tell others how to do a task and, in turn, help them out.

I have the same problem since this morning. A quick scan on nmap revealed that my port 80 is being closed on the remote server. I have advised the support team and waiting for a response.

Hope this helps,

same here. Very strange.
When sshed into my server, "curl localhost" is ok. But external visits will be dinied.

Nobody helped him, and I have the same problem. This doesn't seem very straightforward. I have tried adding port forwarding, but no luck. I wonder if most of what you find is outdated...also, please stop telling people to "Google" when Google is exactly what brought me here.

Did anyone fix it? Got the same problem. Everything was working fine and suddenly this issue appeared.

My 2 cents: it happened to me when having a bad line in the .conf file (in my case a comment was uncommented :P )

Everything was working fine and suddenly this issue appeared +1. I can't find what's wrong 😢


I think it might be some issue with Digital Ocean service. After this reply for several minutes, all connections worked again, I didn't make any changes on my server.

Hi. Its real trouble.
I start Nginx on Ubuntu.
Uwf is disabled.
I use a command "telnet IP 80" to checking server.
When I check it a local or from my other droplet all is ok.
But if I try to connect with 80 port from my local machine this port is silenced.
And when I'am restarting my Nginx on 8080. It works correctly!!!

Hey, DigitalOcean's Devs, fix it, please, ASAP!!! %)

I have the same issue - no firewalls are set up, ufw is inactive, and all traffic to port 80 is refused though there is a server listening on it.

sudo netstat -nlp

returns

tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      19843/nginx -g daem

I can successfully curl the ip address or localhost from the droplet, but from anywhere else the connection is refused. Any server on port 80 will yield the same result, not just an nginx one - and any other port (81, 9000, etc) will work

The droplet version is 16.04.4

Hi,

I was having the same issue. I was getting Connection Refused error when trying to access the site using http://domain.com.
I was able to browse the site by setting any port other than 80 in nginx server listen module.
I checked with 81, 2000 and few more-
http://domain.com:81 was accessible
http://domain.com:2000 was accessible
...

I found a solution of it after many hours-
https://askubuntu.com/questions/676434/port-80-connection-refused

I was missing Reset IPTables firewall rules. I used this link http://insanelabs.net/linux/linux-reset-iptables-firewall-rules/ and did as mentioned.

My issue got fixed.

I posted this answer because may be it could help someone in same situation like mine.

Thanks

  • Thanks, this helped me resolve the issue too!

    • Just as an addendum to this, I used this in conjunction with docker, and for some reason, it causes docker IP tables to be screwy, you might get this error:

      Failed to Setup IP tables: Unable to enable SKIP DNAT rule:  (iptables failed: iptables --wait -t nat -I DOCKER -i br-XXXXXXXXX -j RETURN: iptables: No chain/target/match by that name.
       (exit status 1))
      

      An easy solve is to restart docker:

      sudo systemctl stop docker
      sudo systemctl start docker
      

      Hope that helps!

Have another answer? Share your knowledge.