Report this

What is the reason for this report?

502 bad gateway - 111 connection refused

Posted on November 10, 2017

I’m currently reading the brilliant book “TDD with Python” by Harry Percival and since a few days I’m at that hairy bit where you have to get a droplet at Digital Ocean, create your domain and connect them using some strange spells.

I’m quite confident that I set up my act according to the tutorials: nameserver: $ whois webscraper.pw –> points to the Digital Oceans nameservers

At my domain registrar, I created an A-record pointing to the IP of my droplet.

This is what I do when I SSH into my droplet: $ sudo systemctl start nginx [sudo] password for pippin: $ sudo nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful $ jobs Returns nothing … (is that right??) $ geckodriver -V geckodriver 0.18.0 $ firefox -V Mozilla Firefox 56.0

This is what Django returns: Creating test database for alias ‘default’… System check identified no issues (0 silenced). … self.browser = webdriver.Firefox() … raise exception_class(message, screen, stacktrace) selenium.common.exceptions.WebDriverException: Message: connection refused

And this is what I get from nginx: $ cat /var/log/nginx/error.log 2017/11/10 09:18:01 [error] 5449#5449: *35 connect() failed (111: Connection refused) while connecting to upstream, client: 88.130.52.47, server: staging.webscraper.pw, request: “GET / HTTP/1.1”, upstream: “http://127.0.0.1:8000/”, host: “staging.webscraper.pw” 2017/11/10 09:21:52 [error] 5449#5449: *39 connect() failed (111: Connection refused) while connecting to upstream, client: 88.130.52.47, server: staging.webscraper.pw, request: “GET / HTTP/1.1”, upstream: “http://127.0.0.1:8000/”, host: “207.154.246.158” 2017/11/10 09:21:52 [error] 5449#5449: *39 connect() failed (111: Connection refused) while connecting to upstream, client: 88.130.52.47, server: staging.webscraper.pw, request: “GET /favicon.ico HTTP/1.1”, upstream: “http://127.0.0.1:8000/favicon.ico”, host: “207.154.246.158” 2017/11/10 09:25:15 [error] 5449#5449: *42 connect() failed (111: Connection refused) while connecting to upstream, client: 88.130.52.47, server: staging.webscraper.pw, request: “GET / HTTP/1.1”, upstream: “http://127.0.0.1:8000/”, host: “207.154.246.158” 2017/11/10 10:58:30 [error] 1443#1443: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 155.94.88.58, server: staging.webscraper.pw, request: “GET / HTTP/1.0”, upstream: “http://127.0.0.1:8000/” 2017/11/10 12:40:31 [error] 1443#1443: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 88.130.52.47, server: staging.webscraper.pw, request: “GET / HTTP/1.1”, upstream: “http://127.0.0.1:8000/”, host: “staging.webscraper.pw

If you have any ideas I’d be glad if you share them with me.



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Sorry to see that your question hasn’t received an answer yet. Unfortunately, after this much time, it is unlikely that an answer for this specific question will be provided. For people still landing here via search, a Connection Refused in nginx’s error logs usually means that the upstream server (whatever is running on port 8000 in this case) isn’t running. I’d recommend to start by making sure that it is running and that the ports are configured correctly. If that doesn’t fix it, check the logs of the upstream server.

I concur with the answer given by kamain7. I had the same issue and upon further investigation into the upstream server, even though a ‘docker ps’ showed it up and running, was not serving pages properly.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.