HTTP 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
Start free, or choose a plan, for 30-second monitoring and alert confirmation.
from $3/mo · 30-day money-back guarantee
Other HTTP status codes
- HTTP 503 Service Unavailable
- HTTP 502 Bad Gateway
- HTTP 500 Internal Server Error
- HTTP 520 Web Server Returns Unknown Error
- HTTP 522 Connection Timed Out
- HTTP 451 Unavailable For Legal Reasons
- HTTP 429 Too Many Requests
- HTTP 422 Unprocessable Entity
- HTTP 415 Unsupported Media Type
- HTTP 413 Payload Too Large
- HTTP 410 Gone
- HTTP 409 Conflict
- HTTP 408 Request Timeout
- HTTP 405 Method Not Allowed
- HTTP 404 Not Found
- HTTP 403 Forbidden
- HTTP 401 Unauthorized
- HTTP 400 Bad Request
- HTTP 304 Not Modified
- HTTP 302 Found
- HTTP 301 Moved Permanently
- HTTP 204 No Content
- HTTP 201 Created
- HTTP 200 OK