Increasing 504 timeout error

NginxTimeoutFastcgiGateway

Nginx Problem Overview


Is there any way I can make the error 504 gateway timeout longer if so how and where is the file to change it located. I am using nginx on centos 6

Nginx Solutions


Solution 1 - Nginx

Depending on the kind of gateway you have you should use something like:

proxy_read_timeout 600s;

Check docs: http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_read_timeout

Solution 2 - Nginx

If it is a fastcgi timeout error, then you need to increase the fastcgi_read_timeout.

# /etc/nginx/conf.d/example.com.conf
server {

    location ~ \.(php)$ {
        fastcgi_pass unix:/var/run/php74-example.com.sock;
        fastcgi_read_timeout 300s;

error log) upstream timed out

# tail -f example.com.error.log
2020/12/29 14:51:42 [error] 30922#30922: 
*9494 upstream timed out (110: Connection timed out) while reading response header from upstream,
...
upstream: "fastcgi://unix:/var/run/php74-example.com.sock",
...

nginx manual)

Default: fastcgi_read_timeout 60s;
Context: http, server, location

http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_read_timeout


Result of calling a script that runs for longer then 60 seconds in Chrome DevTools.

default 60s

enter image description here

fastcgi_read_timeout 300s

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMatthew JonesView Question on Stackoverflow
Solution 1 - NginxkworrView Answer on Stackoverflow
Solution 2 - NginxBeen Kyung-yoonView Answer on Stackoverflow