Question

Problem: "502 Bad Gateway nginx/1.10.3 (Ubuntu)"

Hi, after the NYC3 Droplet Reboot 2018-02-22 17:00 UTC [Spectre and Meltdown Mitigation] my site is down and I get “502 Bad Gateway nginx/1.10.3 (Ubuntu)”. I found these nginx’s error logs:

2018/02/22 22:35:04 [error] 1571#1571: *448 connect() failed (111: Connection refused) while connecting to upstream, client: 104.131.85.203, server: 45.55.205.197, request: "GET /api371878927a/running.txt HTTP/1.0", upstream: "http://127.0.0.1:2368/api371878927a/running.txt", host: "45.55.205.197" 
2018/02/22 22:35:04 [error] 1571#1571: *449 connect() failed (111: Connection refused) while connecting to upstream, client: 104.131.85.203, server: 45.55.205.197, request: "GET /api371878927a/remote_addr.php?hostname=adsp-xv-us-nyc HTTP/1.0", upstream: "http://127.0.0.1:2368/api371878927a/remote_addr.php?hostname=adsp-xv-us-nyc", host: "45.55.205.197" 
2018/02/22 22:35:38 [error] 1571#1571: *452 connect() failed (111: Connection refused) while connecting to upstream, client: 66.249.81.62, server: strangerthancinema.it, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:2368/favicon.ico", host: "strangerthancinema.it" 
2018/02/22 22:36:04 [error] 1571#1571: *454 connect() failed (111: Connection refused) while connecting to upstream, client: 104.131.85.203, server: 45.55.205.197, request: "GET /api371878927a/running.txt HTTP/1.0", upstream: "http://127.0.0.1:2368/api371878927a/running.txt", host: "45.55.205.197" 
2018/02/22 22:36:20 [error] 1571#1571: *456 connect() failed (111: Connection refused) while connecting to upstream, client: 66.249.81.60, server: strangerthancinema.it, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:2368/favicon.ico", host: "strangerthancinema.it" 
2018/02/22 22:37:04 [error] 1571#1571: *458 connect() failed (111: Connection refused) while connecting to upstream, client: 104.131.85.203, server: 45.55.205.197, request: "GET /api371878927a/running.txt HTTP/1.0", upstream: "http://127.0.0.1:2368/api371878927a/running.txt", host: "45.55.205.197" 
2018/02/22 22:38:04 [error] 1571#1571: *462 connect() failed (111: Connection refused) while connecting to upstream, client: 104.131.85.203, server: 45.55.205.197, request: "GET /api371878927a/running.txt HTTP/1.0", upstream: "http://127.0.0.1:2368/api371878927a/running.txt", host: "45.55.205.197" 
2018/02/22 22:38:37 [error] 1571#1571: *466 connect() failed (111: Connection refused) while connecting to upstream, client: 66.249.93.94, server: strangerthancinema.it, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:2368/favicon.ico", host: "strangerthancinema.it" 
2018/02/22 22:38:43 [error] 1571#1571: *468 connect() failed (111: Connection refused) while connecting to upstream, client: 151.50.140.189, server: 45.55.205.197, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:2368/", host: "45.55.205.197" 
2018/02/22 22:38:44 [error] 1571#1571: *468 connect() failed (111: Connection refused) while connecting to upstream, client: 151.50.140.189, server: 45.55.205.197, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:2368/favicon.ico", host: "45.55.205.197", referrer: "http://45.55.205.197/" 
2018/02/22 22:39:00 [error] 1571#1571: *474 connect() failed (111: Connection refused) while connecting to upstream, client: 66.249.81.33, server: strangerthancinema.it, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:2368/favicon.ico", host: "strangerthancinema.it" 
2018/02/22 22:39:04 [error] 1571#1571: *476 connect() failed (111: Connection refused) while connecting to upstream, client: 104.131.85.203, server: 45.55.205.197, request: "GET /api371878927a/running.txt HTTP/1.0", upstream: "http://127.0.0.1:2368/api371878927a/running.txt", host: "45.55.205.197" 

How do I resolve this problem ? Thanks

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.

cd /path/to/webroot to change your directory to the webroot

ls -la will print out the info you need

Depending if you have NGINX running as www-data or nginx as the user:group you may need to update

chown -R www-data:www-data /path/to./webroot

Ensure your webroot has the correct ownership and permissions

As well nginx -t will let you know of any errors in your NGINX configuration file(s) if any are present.

Izinkan

Also, try this:

sudo nano /etc/nginx/sites-enabled/default

What you are looking for is the proxy_pass http://localhost:${Port}/

 ${Port} = your localhost port ex. 8080, 3000, or yours is 2368

Your proxy_pass config is missing the forward slash ( / ) at the end after the port number.

It should look like proxy_pass http://localhost:2368/; not 2368;

hope this helps

If you are still getting the ‘welcome to nginx’ when you got to the URL, try restarting nginx and the hard refreshing your browser.

Try running this command chown -Rf nginx:nginx /var/www. If that doesn’t work, it could have something to do with php-fpm. I would try to make sure that is enabled and on if your website is dependent on php-fpm (example, WordPress)

I created a new /sites-available/default only with your indications. Back to “502 bad gateway”.

This comment has been deleted