By boblesueur
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.
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!
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:
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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.