Gunicorn Nginx Timeout Issue

I am running django on gunicorn + nginx. I have a problem downloading files. Actually the downloaded files work fine, but the vacation time is what causes 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 see that all the photos are uploaded just fine. The problem is that it causes a timeout, giving the impression that the download is not working.

here is my gunicorn conf:

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

I tried to change the timeout, but it did not work.

+44
django nginx gunicorn
Jul 25 '11 at 12:36
source share
4 answers

You can try updating the timeout for the proxy server 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 on all sites served by nginx.

You must add --timeout 300 as well as your gun / configuration process.

In the past, this solved my problems with large downloads.

+63
Mar 29 '12 at 18:24
source share

This is not a nginx timeout, but probably a Gunicorn timeout. Gunicorn defaults to a timeout of 30 seconds.

In general, you should fix this without returning an endpoint that takes more than 30 seconds, but if this is a rarely used endpoint, you can also simply increase the gun timeout. If you do this, you probably should also increase the number of artillery workers.

To increase the timeout and workers for the gun, you can add the following command line options on the command line:

gunicorn --timeout 120 - workers

+24
Apr 21 '13 at 3:33
source share

We had the same problem using Django + nginx + gunicorn. From the Gunicorn documentation, we set up a graceful timeout that was almost the same.

After some tests, we found a solution, an option to configure: timeout (And not a graceful timeout). It works like a clock.

So Do:

1) open the gun configuration file,

2) set TIMEOUT at any time - the value is in seconds

 NUM_WORKERS=3 TIMEOUT=120 exec gunicorn ${DJANGO_WSGI_MODULE}:application \ --name $NAME \ --workers $NUM_WORKERS \ --timeout $TIMEOUT \ --log-level=debug \ --bind=127.0.0.1:9000 \ --pid=$PIDFILE 
+10
Jun 19 '14 at 11:50
source share

This may help someone with a similar problem.

I was getting a timeout error from nginx and gunicorn in my Django application. Since I was getting a timeout error from nginx, I could not see the real error from Django. After adding a new timeout, for example, suggested by fijter. I saw that the error was in the settings.py file.

If you set DEBUG to False and have not added the domain name to ALLOWED_HOSTS, you may get this error.

I just added a domain to ALLOWED_HOSTS in settings.py and the error went away.

A very simple solution!

0
Jun 16 '16 at 0:34
source share



All Articles