On a local development machine, I have a nginx reverse proxy like so:
server {
listen 80;
server_name myvirtualhost1.local;
location / {
proxy_pass http://127.0.0.1:8080;
}
server {
listen 80;
server_name myvirtualhost2.local;
location / {
proxy_pass http://127.0.0.1:9090;
}
Yet if I debug my application, the response may be delayed for an infinite amount of time, yet after 30 seconds I get:
504 Gateway Time-out
as a response.
How can I disable the timeout and have my reverse proxy wait forever for a response? And I like the setting to be global, so that I do not have to set it for each proxy.
It may not be possible to disable it at all, yet a feasible workaround is to increase the execution time. On a nginx tutorial site, it was written:
and reload nginx' config:
I have used a rather large value that is unlikely to happen, i.e.
999999
or using time units, to one day via1d
.Beware that setting the value to
0
will cause a gateway timeout error immediately.It is possible to increase the timeout for nginx, to add to @k0pernikus 's answer, the following can be added to your location block:
Here 1800 is in seconds.
After changing the config, verify the syntax with:
Then reload nginx with:
If you are using AWS, and Load Balancer, you should edit Idle timeout. I think default is 60 seconds
I've been fighting with nginx 502 timeout error and could not solve the issue. However, it happened to be gunicorn causing the timeout error. So you might also need to check your fastcgi settings.
For gunicorn it's: