How to Increase Request Timeout in the NGINX

Overview

Sometimes the long-running requests failed with the error message “504: Gateway Timeout” in the NGINX web server. To solve this issue, you need to increase the request timeout in the NGINX server configuration. The default, NGINX request timeout is 60 seconds. Which can be increased or decreased by updating the configuration files. In this article, you will learn to change the request timeout in the NGINX web server.

 

Information

For example, you want to increase request timeout to 300 seconds. Then you need to add proxy_read_timeoutproxy_connect_timeoutproxy_send_timeout directives to http or server block. Here the http block allows the changes in all servers in NGINX.

To make changes for all servers, edit the NGINX main configuration file and add the following content under the HTTP block.

http{
   ...
   proxy_read_timeout 300;
   proxy_connect_timeout 300;
   proxy_send_timeout 300;
   ...
}

After making the changes, you must restart the NGINX service to apply changes. The systems running with systemd can use the following command.

sudo systemctl restart nginx 

All done. With the above changes, you have successfully increased the request timeout in the NGINX server.

Comments

Article is closed for comments.