Michael
Michael

Reputation: 833

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/"

Upvotes: 3

Views: 6384

Answers (1)

Kirill Bubochkin
Kirill Bubochkin

Reputation: 6343

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).

Upvotes: 7

Related Questions