Question

Mern stack droplet 502 Bad Gateway nginx/1.24.0 (Ubuntu)

Hi again, I spun up a new droplet and can’t get the app to appear. Please help as I’m at a loss, thanks!

Following is my error log.

root@outdoors3:~/the_outdoors_club# tail -f /var/log/nginx/error.log
2024/06/25 17:28:46 [error] 1204#1204: *21 connect() failed (111: Connection refused) while connecting to upstream, client: 24.193.166.172, server: outdoors.rest, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5050/", host: "outdoors.rest"
2024/06/25 17:28:47 [error] 1204#1204: *21 no live upstreams while connecting to upstream, client: 24.193.166.172, server: outdoors.rest, request: "GET /favicon.ico HTTP/1.1", upstream: "http://localhost/favicon.ico", host: "outdoors.rest", referrer: "https://outdoors.rest/"
2024/06/25 17:29:32 [alert] 1204#1204: *22 open socket #13 left in connection 6
2024/06/25 17:29:32 [alert] 1204#1204: aborting
2024/06/25 17:29:38 [error] 1869#1869: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 24.193.166.172, server: outdoors.rest, request: "GET / HTTP/1.1", upstream: "http://[::1]:5050/", host: "outdoors.rest"
2024/06/25 17:29:38 [error] 1869#1869: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 24.193.166.172, server: outdoors.rest, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5050/", host: "outdoors.rest"
2024/06/25 17:29:39 [error] 1869#1869: *1 no live upstreams while connecting to upstream, client: 24.193.166.172, server: outdoors.rest, request: "GET /favicon.ico HTTP/1.1", upstream: "http://localhost/favicon.ico", host: "outdoors.rest", referrer: "https://outdoors.rest/"
2024/06/25 17:38:11 [error] 1869#1869: *10 connect() failed (111: Connection refused) while connecting to upstream, client: 24.193.166.172, server: outdoors.rest, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5050/", host: "outdoors.rest"
2024/06/25 17:38:11 [error] 1869#1869: *10 connect() failed (111: Connection refused) while connecting to upstream, client: 24.193.166.172, server: outdoors.rest, request: "GET / HTTP/1.1", upstream: "http://[::1]:5050/", host: "outdoors.rest"
2024/06/25 17:38:13 [error] 1869#1869: *10 no live upstreams while connecting to upstream, client: 24.193.166.172, server: outdoors.rest, request: "GET /favicon.ico HTTP/1.1", upstream: "http://localhost/favicon.ico", host: "outdoors.rest", referrer: "https://outdoors.rest/"
2024/06/25 17:48:22 [error] 1869#1869: *30 connect() failed (111: Connection refused) while connecting to upstream, client: 24.193.166.172, server: outdoors.rest, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5050/", host: "outdoors.rest"
2024/06/25 17:48:22 [error] 1869#1869: *30 connect() failed (111: Connection refused) while connecting to upstream, client: 24.193.166.172, server: outdoors.rest, request: "GET / HTTP/1.1", upstream: "http://[::1]:5050/", host: "outdoors.rest"
2024/06/25 17:48:23 [error] 1869#1869: *30 no live upstreams while connecting to upstream, client: 24.193.166.172, server: outdoors.rest, request: "GET /favicon.ico HTTP/1.1", upstream: "http://localhost/favicon.ico", host: "outdoors.rest", referrer: "https://outdoors.rest/"

This is my nginx config file



server {

        index index.html index.htm index.nginx-debian.html;

        server_name outdoors.rest www.outdoors.rest;



        location / {

                proxy_pass http://localhost:5050;

                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

        }



         location /api {

            proxy_pass http://localhost:5050/api;

            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 ipv6only=on; # managed by Certbot

    listen 443 ssl; # managed by Certbot

    ssl_certificate /etc/letsencrypt/live/outdoors.rest/fullchain.pem; # managed by Certbot

    ssl_certificate_key /etc/letsencrypt/live/outdoors.rest/privkey.pem; # managed by Certbot

    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot

    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
Show comments

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.

I think that the above happened because i took a snapshot and the droplet became corrupted. I spun up a new droplet and it’s working as before, so no need to answer, thanks!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel