I have Nginx + uWSGI for Python Django app.
I have the following in my nginx.conf
:
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9001;
uwsgi_read_timeout 1800;
uwsgi_send_timeout 300;
client_header_timeout 300;
proxy_read_timeout 300;
index index.html index.htm;
}
but for long running requests on uWSGI which takes about 1 minute to complete I get a timeout error in Nginx error log as below:
2013/04/22 12:35:56 [error] 2709#0: *1 upstream timed out (110: Connection timed out) while reading response header from upstream, client: xx.xx.xx.xx, server: , request: "GET /entity/datasenders/ HTTP/1.1", upstream: "uwsgi://127.0.0.1:9001", host: "xxx.xx.xx.x"
I have already set the header time out and the uWSGI send/read timeouts to 5 mins, can someone please tell me what I can do to overcome this?
In addition to the "uwsgi_read_timeout" answer, you should also check that ownership is correct for your nginx uwsgi cache directory. Ownership must be set to the same user as the running nginx process... In my case I had to do this
Are these files owned by the same user? If not, you could shut down nginx and remove all the cache files, make sure that the proper owner is on /var/cache/nginx/uwsgi_temp and restart. Maybe you could also just do a recursive chown, I didn't test this approach.
Remove cache and restart approach
Recursive chown approach
The configuration that solves the problem is:
The reason the above configuration in the question did not work for us because unfortunately in our machine multiple paths had
nginx.conf
file. We were working with the conf at the wrong path.To correctly figure out which path your nginx is picking up the configuration from run:
this will have a
--conf-path=[]
which will tell you exactly from where it is picking up the configuration from.I recently found the above
nginx -V
to not give the right info. I will leave the above just in case others find it useful.