Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

django - 110: Connection timed out (Nginx/Gunicorn)

I'm running django on gunicorn+nginx. I'm facing a problem with file uploads. Actually uploads are working fine but gunicorn times out thus causing this in nginx:

2011/07/25 12:13:47 [error] 15169#0: *2317 upstream timed out (110: Connection timed out) while reading response header from upstream, client: IP-ADDRESS, server: SERVER, request: "GET /photos/events/event/25 HTTP/1.1", upstream: "http://127.0.0.1:29000/photos/events/event/25", host: "HOST", referrer: "REFERER_ADDRESS"

If I refresh the page, I can see all the photos are uploaded just fine. The problem is that it causes a timeout thus giving the impression that upload did not work.

here is my gunicorn conf:

bind = "127.0.0.1:29000"
logfile = "/path/to/logs/gunicorn.log"
workers = 3

I tried changing timeout but it didn't work.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You could try upgrading the timeout for your proxy pass in Nginx by adding:

proxy_connect_timeout 75s;
proxy_read_timeout 300s;

on /var/nginx/sites-available/[site-config] or /var/nginx/nginx.conf if you want to increase the timeout limite on all sites served by nginx.

You must add --timeout 300 as well to your gunicorn process/config.

This solved my problems in the past with bigger uploads.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...