Question

502 Bad Gateway nginx/1.10.3 (Ubuntu) after server reboot

Took over the website for a company. After resetting the server password and rebooting the server, the site is now giving a “502 Bad Gateway nginx/1.10.3 (Ubuntu)” error.

Checked the nginx error logs and getting several errors similar to this (replaced client IP and website name for privacy):

2018/09/02 19:09:09 [error] 4531#4531: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 0.0.0.0, server: mywebsite.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:3035/favicon.ico", host: "mywebsite.com", referrer: "https://mywebsite.com/"

Checked /etc/nginx/sites-available/default and this is the config (again, site has been changed for privacy):

server { #80 IS THE USUAL PORT TO USE HERE

     server_name mywebsite.com www.mywebsite.com; #PUT YOU$

     location / {
          proxy_pass http://127.0.0.1:3035; #PUT YOUR SERVER PORT HERE
          proxy_http_version 1.1;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection 'upgrade';
          proxy_set_header Host $host;
          proxy_cache_bypass $http_upgrade;
     }

     listen 443 ssl; # managed by Certbot
     ssl_certificate /etc/letsencrypt/live/mywebsite.com/fullchain.pe$
     ssl_certificate_key /etc/letsencrypt/live/mywebsite.com/privkey.$
     include /etc/letsencrypt/options-ssl-nginx.conf; # managed by certbot
     ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by certbot


}
server {
     if ($host = www.mywebsite.com) {
          return 301 https://$host$request_url;
     } # managed by Certbot


     if ($host = mywebsite.com) {
          return 301 https://$host$request_url;
     } # managed by Certbot


     listen 80;

     server_name mywebsite.com www.mywebsite.com;
     return 404: # managed by Certbot




}

Tried several suggestions found through community and can’t seem to get this to work. Any help would be greatly appreciated.


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hi there,

Just came across this question in 2020. Here are some suggestions for anyone who might need this:

Here is a link to an answer on how to troubleshoot common Nginx problems:

https://www.digitalocean.com/community/questions/how-to-troubleshoot-common-nginx-issues-on-linux-server

And here is also a quick video demo on how to do that as well:

Regards, Bobby

Were you ever able to solve this issue? We are having the exact same problem and nothing seems to work