Changing Nginx request timeout

Calls fired by my application suddenly started to timeout in a production environment. A colleague was quick to point towards the web server. Nginx has a default time out value of 60 seconds. In this case, the requests were large data imports which frequently took more than a minute. Changing the timeout in Nginx is easy.

In the Nginx configuration, the 'proxy_read_timeout' directive can be placed anywhere within the http context, as per the Nginx documentation.

http
{
  server
  {
    …
    location /
    {
         …
         proxy_read_timeout 180s;
        …
    }
  }
}

After changing the configuration, reload the web server for the changes to take effect.

service nginx reload

 

Sources:

nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout
doublecloud.org/2014/03/nginx-how-to-fix-timeout-issues-and-more/