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
Asked
Active
Viewed 1.2e+01k times
85
-
In my case, I was using nginx with a load balancer, so I had to update the haproxy config to increase the server timeout `timeout server 3000s` – fungusanthrax Jul 29 '21 at 21:15
2 Answers
139
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

kworr
- 3,579
- 1
- 21
- 33
-
9I found that https://www.scalescale.com/tips/nginx/504-gateway-time-out-using-nginx/ has some additional timeout settings mentioned. That could also be helpful in this regard. – Jakob Runge Mar 11 '16 at 13:24
-
1Well I tried to answer the question first. Other options mentioned there are not about nginx or not about fixing error 504 (except *_connect_timeout porbably... but that's rather about network connection issues). – kworr Mar 12 '16 at 20:51
-
Yes, I'm aware of that and I also found your answer helpful a good deal to me. Just thought that the additional info might help others as well .) – Jakob Runge Mar 12 '16 at 23:03
-
1
-
1@DavidLin, you are right, though seconds are default, measurement units should be added per http://nginx.org/en/docs/syntax.html – kworr Nov 25 '17 at 08:47
-
Make sure to create a new file and add it to /nginx/conf.d/ folder rather than editing /nginx/nginx.conf folder directly. This is better for portability and to easily see and edit past changes. – DavidR Aug 27 '18 at 21:56
5
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
fastcgi_read_timeout 300s

Been Kyung-yoon
- 1,644
- 12
- 13