504
Gateway Timeout
The server acting as a gateway or proxy did not receive a timely response from the upstream server. The proxy waited for the backend to respond but the request took longer than the configured timeout.
What does HTTP 504 mean?
The server acting as a gateway or proxy did not receive a timely response from the upstream server. The proxy waited for the backend to respond but the request took longer than the configured timeout.
Common causes
- 1
The upstream application server is too slow — a heavy database query, external API call, or CPU-intensive operation exceeded the proxy timeout.
- 2
Network latency or connectivity issues between the proxy and upstream server. Packets are being delayed or dropped.
- 3
The upstream server is deadlocked, stuck in an infinite loop, or blocked on I/O, preventing it from responding at all.
How to fix it
- 1
Identify and optimize the slow operation. Check for unindexed database queries, N+1 query patterns, or slow external API calls that should be made asynchronous.
- 2
Increase the proxy timeout as a temporary fix: proxy_read_timeout in nginx, timeout in HAProxy. But address the root cause — raising timeouts masks performance problems.
- 3
Add request timeouts to external API calls in your application code. Use circuit breakers to fail fast instead of hanging when a dependency is slow.
Monitor for HTTP 504 errors
A 504 means your app is too slow for the proxy layer. Uptrack tracks response times alongside status codes, so you can spot latency degradation before it escalates into full 504 timeouts.
Catch HTTP errors before your users do
20 monitors free — 10 at 30s, 10 at 1min. No credit card required.
Start Monitoring Free