Slow query or job
A report, export or database query takes longer than the proxy is willing to wait.
Monitor
Protect
Manage
By role
Security
Renewals
Monitoring
A 504 Gateway Timeout means a server acting as a gateway or proxy did not get a response from the upstream server in time. The upstream is usually slow or hung, or a timeout setting is lower than the work takes. Reloading rarely helps if the slow request repeats.
| Code | Who timed out | Meaning |
|---|---|---|
| 504 Gateway Timeout | The proxy waited for upstream | No upstream response in time |
| 502 Bad Gateway | Nobody timed out | Upstream answered with an invalid response |
| 408 Request Timeout | The server waited for the client | The server closed an idle connection |
| 524 (Cloudflare) | Cloudflare waited for your origin | Connected, but no response before the read timeout |
A report, export or database query takes longer than the proxy is willing to wait.
All workers are busy, so the request waits in a queue until the proxy gives up.
The app waits on an external API or payment provider that does not answer.
Packet loss or a firewall drop between proxy and upstream stalls the connection.
The app server waits on name lookups for a database or API host.
The proxy timeout is shorter than legitimate requests need.
# defaults: 60s each
proxy_connect_timeout 60s; # establish the connection (usually cannot exceed 75s)
proxy_send_timeout 60s; # between two writes to the upstream
proxy_read_timeout 60s; # between two reads from the upstream
# PHP-FPM / FastCGI: same defaults
fastcgi_read_timeout 60s;The read and send timeouts apply between successive operations, not to the whole response (nginx proxy module). Raise a timeout only after you know why the request is slow.
One slow endpoint points at a query or job. Every URL points at the upstream or network.
Request the app server bypassing the proxy and time it with curl -w "%{time_total}\n" -o /dev/null -s URL.
Match the proxy timeout line to the app log entry for the same request and see where time went.
Index the query, cache the result, or move long jobs to a background queue and poll for status.
For legitimate long requests, raise the proxy read timeout. Cloudflare also has its own limits, see the 524 row above.
If others can load the site, check your VPN, proxy, firewall and DNS settings, as MDN suggests.
It means a gateway or proxy waited for the upstream server and got no response within its time limit. The proxy itself works. Either the upstream is too slow or down, or the proxy timeout is shorter than the request needs.
Usually not. Reload once, try again in a few minutes, and test from another network. If the site works for others, check your VPN, proxy, firewall and DNS settings. Otherwise tell the site owner.
Both come from a gateway. A 502 means the upstream replied with something invalid. A 504 means it did not reply in time. A 502 suggests a crashed or misconfigured upstream, while a 504 suggests a slow or hung one.
Only if the request is legitimately long. A higher timeout hides a slow query and ties up workers, which can cause 503s under load. Fix or background the slow work first, then size timeouts to the real maximum.
Cloudflare returns 524 when your origin accepts the connection but does not respond before its read timeout, which is 125 seconds by default. A true 504 can also come from your own proxy, load balancer or host in front of the origin.
Aepto monitors expiry, DNS, SSL and uptime for every domain you own and alerts you when something changes. Free for 3 domains.