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?
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 @rikeshk012330,
It looks like that your Gunicorn service has crashed and Nginx is unable to connect to it.
To fix the error you have to start the Gunicorn service.
For more information on how to troubleshoot 502 Nginx errors, I could suggest following the steps from this answer here:
https://www.digitalocean.com/community/questions/502-bad-gateway-nginx-2
Regards, Bobby
Gunicorn is working. My memory logs are:
root@develop-110:~# free -m
total used free shared buff/cache available
Mem: 3936 354 2308 12 1272 3283
Swap: 0 0 0
Only with large file uploads, I have 502 gateway errors
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.