Report this

What is the reason for this report?

How to fix 502 Bad Gateway error message?

Posted on December 31, 2020

I was trying to upload a data file of around 600 MB in my project which is hosted in digital ocean. It tries to upload but 502 Bad Gateway Nginx error is shown.

While the upload completely works fine on my local system.

When I tried:

sudo tail -30 /var/log/nginx/error.log

It shows:

[error] 132235#132235: *239 upstream prematurely closed connection while reading response header from upstream, client: client's ip, server: ip, request: "POST /submit/ HTTP/1.1", upstream: "http://unix:/run/gunicorn.sock:/submit/", host: "ip", referrer: "http://ip"

After,

sudo nano /etc/nginx/sites-available/myproject

the nginx code

server {
    listen 80;
    server_name ip;
    client_max_body_size 999M;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
       alias  /root/static/;
    }
    location / {
        include proxy_params;
        proxy_pass http://unix:/run/gunicorn.sock;
    }
}

How to fix this?

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.