Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx gunicorn 502 bad gateway: upstream prematurely closed connection while reading response header from upstream

I have a Django app with which users can create video collages using multiple videos. Problem is, on production, when uploading videos to amazon s3, I get a 502 bad gateway (works fine locally). Does anyone know what could be wrong? I already set

client_max_body_size 100M

and

fastcgi_buffers 8 16k;
fastcgi_buffer_size 32k;
fastcgi_connect_timeout 3000;
fastcgi_send_timeout 3000;
fastcgi_read_timeout 3000;

Does anyone know what could be wrong? Thanks in advance

Full error:

2017/12/31 23:50:51 [error] 1279#1279: *1 upstream prematurely closed connection while reading response header from upstream, 
client: 107.205.110.154, 
server: movingcollage.com, 
request: "POST /create-collage/ HTTP/1.1", 
upstream: "http://unix:/home/mike/movingcollage/movingcollage.sock:/create-collage/", 
host: "movingcollage.com", referrer: "http://movingcollage.com/create-collage/"
like image 446
Michael Avatar asked Jan 27 '26 04:01

Michael


1 Answers

If the problem were in nginx timeout it would give you 504 error. 502 error means that this error could happen due to timeout in process behind nginx, gunicorn in your case I guess. Try to launch it with -t 3000 param (to match your nginx conf).

like image 193
Kirill Bubochkin Avatar answered Jan 28 '26 18:01

Kirill Bubochkin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!