Skip to content
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

Back to the full HTTP status code reference