How to disable timeout for nginx?

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:

If you want to increase time-limit for all-sites on your server, you can edit main nginx.conf file:

vim /etc/nginx/nginx.conf

Add following in http{..} section

http {
     fastcgi_read_timeout 300;
     proxy_read_timeout 300;
}

and reload nginx' config:

sudo service nginx reload

I have used a rather large value that is unlikely to happen, i.e. 999999 or using time units, to one day via 1d.

Beware that setting the value to 0 will cause a gateway timeout error immediately.


If you are using AWS, and Load Balancer, you should edit Idle timeout. I think default is 60 seconds