5xx Server Error
Safe to retry
504 Gateway Timeout
A proxy waited for an upstream response and gave up.
What causes it
- A slow query or an external API call exceeding the proxy timeout.
- nginx `proxy_read_timeout` (default 60 s); AWS ALB idle timeout (default 60 s); Cloudflare (100 s).
- A deadlock or an infinite loop in the upstream handler.
How to fix it
- Find the slow operation first — raising the timeout hides the problem and makes an outage last longer.
- For genuinely long jobs, return 202 with a polling URL instead of holding the connection open.
- Every hop has its own timeout; raise them consistently or the shortest one wins.
At a glance
- Class
- 5xx Server Error
- Reference
- RFC 9110 §15.6.5
- Standardised
- Yes
- Retry the request?
- Yes, with backoff
Other 5xx server error codes
- 500 Internal Server Error
- 501 Not Implemented
- 502 Bad Gateway
- 503 Service Unavailable
- 505 HTTP Version Not Supported
- 506 Variant Also Negotiates
- 507 Insufficient Storage
- 508 Loop Detected
- 510 Not Extended
- 511 Network Authentication Required
- 520 Web Server Returned an Unknown Error
- 521 Web Server Is Down
- 522 Connection Timed Out
- 523 Origin Is Unreachable
- 524 A Timeout Occurred
- 525 SSL Handshake Failed
- 526 Invalid SSL Certificate