Question

Nginx 502 Error after restart can't find source of issue

  • Posted December 8, 2020
  • Nginx

Hello!

I hope someone can help me with this issue. I’ve seen a lot of similar issues on this board but nothing has been able to help me so far.

The server is used to generate data feeds and read/write data to shopify. There were issues with feeds being generated so I power cycled the server. Since then I get the generic 502 error message on my web browser. I then rolled back to a week old back up and that didn’t fix anything.

Here is what the Nginx error log looks like:

2020/12/08 12:26:49 [error] 1567#0: *8 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 104.32.213.164, server: t.mydomain.com, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/mydomain.sock:/", host: "t.mydomain.com"
2020/12/08 12:26:50 [error] 1567#0: *8 connect() to unix:/var/run/mydomain.sock failed (111: Connection refused) while connecting to upstream, client: 104.32.213.164, server: t.mydomain.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:/var/run/mydomain.sock:/favicon.ico", host: "t.mydomain.com", referrer: "https://t.mydomain.com/"
2020/12/08 12:42:24 [error] 1624#0: *1 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: 13.56.215.207, server: t.mydomain.com, request: "GET / HTTP/1.1", upstream: "http://unix:/var/run/mobovidata.sock:/", host: "mydomain.com"

I am also getting this when I run the nginx command

2020/12/07 20:49:24 [emerg] 21240#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2020/12/07 20:49:24 [emerg] 21240#0: bind() to 0.0.0.0:443 failed (98: Address already in use)
2020/12/07 20:49:24 [emerg] 21240#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2020/12/07 20:49:24 [emerg] 21240#0: bind() to 0.0.0.0:443 failed (98: Address already in use)
2020/12/07 20:49:24 [emerg] 21240#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2020/12/07 20:49:24 [emerg] 21240#0: bind() to 0.0.0.0:443 failed (98: Address already in use)
2020/12/07 20:49:24 [emerg] 21240#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2020/12/07 20:49:24 [emerg] 21240#0: bind() to 0.0.0.0:443 failed (98: Address already in use)
2020/12/07 20:49:24 [emerg] 21240#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2020/12/07 20:49:24 [emerg] 21240#0: bind() to 0.0.0.0:443 failed (98: Address already in use)

I know nothing about this stuff but what I have been able to gather is that the issue might be with gunicorn not starting correctly. None of the config files were touched, we just did a power cycle.

Can anyone help? Please let me know if you need any more log or conf details.

THANK YOU!

Subscribe
Share

Submit an 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.

Hi there @rubenmv1,

It sounds like your Gunicorn service did not start after the server reboot.

You would need to make sure that you start the service and then you also enable it so that the next time the server reboots the service could start automatically.

For more information on how to set that up, make sure to go through this article here:

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04#create-a-gunicorn-systemd-service-file

Regards, Bobby