Question

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

Posted September 2, 2018 6.5k views
NginxUbuntu 16.04

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.

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.

×
1 answer

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

Submit an Answer