How to Increase Request Timeout in NGINX


This problem occurred when you install or create your own server,  and also on any system like local or Live. The long running requests failed with the error message “504: Gateway Timeout” in NGINX web server. To solve this issue, you need to increase request timeout in NGINX server configuration. The default, NGINX request timeout is 60 seconds. Which can be increased or decreased by updating the configuration files. 

In case, you want to increase request timeout to 300 seconds. Then you need to add proxy_read_timeout, proxy_connect_timeout, proxy_send_timeout directives to http or server block. Here the http block allows the changes in all server in NGINX.  To make changes for all servers, edit the NGINX main configuration file and add the following content under http block.


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


In case, you just want to increase request timeout for a specific server or subdomain, then add the directives for its server block only. Edit the specific server block configuration file and add the following settings:


server{    
...
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 




Conclusion

This post will helps you to increase request timeout in NGINX web server.

Post a Comment

Previous Post Next Post