Report this

What is the reason for this report?

Can't figure out 502 Bad Gateway issue

Posted on July 19, 2018

My nodejs / expressjs site that I run using forever is giving the following error:

502 bad gateway (nginx/1.6.2)

Weird thing is I didn’t change anything. The error has been showing up for a couple months, but I haven’t made any changes for half a year.

The error from sudo tail -f /var/log/nginx/error.log looks like this (removed my ip and actual site name):

2018/07/19 12:38:49 [error] 1852#0: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 111.11.1.111, server: mysite.com, request: “GET /favicon.ico HTTP/1.1”, upstream: “http://127.0.0.1:3010/favicon.ico”, host: “mysite.com”, referrer: “http://mysite.com/

My nginx conf looks like this:


server {
        listen 80;
        server_name www.mysite.com;
        return 301 $scheme://mysite.com$request_uri;
}

server {
    listen 80;

    server_name mysite.com;

    location / {
        proxy_pass http://localhost:3010;
        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;
    }
}

Help please!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.