Nginx timeouts when uWSGI takes long to process request
Solution 1:
The configuration that solves the problem is:
location / {
include uwsgi_params;
uwsgi_pass 127.0.0.1:9001;
uwsgi_read_timeout 300;
index index.html index.htm;
}
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:
nginx -V # V is caps
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.
Solution 2:
Solved by changing the following Nginx config
proxy_connect_timeout 300;
proxy_read_timeout 300;
client_body_timeout 300;
client_header_timeout 300;
keepalive_timeout 300;
And UWSGI setting
http-timeout = 300 // or 'socket-timeout = 300' depending on uwsgi setting