At One Place

HTTP 504 — Gateway Timeout

HTTP 504
Gateway Timeout
A proxy or gateway waited for the server behind it and gave up before an answer arrived.

What 504 actually means

Like a 502, this comes from an intermediary reporting on the server behind it — but here the upstream was alive and simply too slow. The proxy hit its timeout and returned an error rather than waiting forever. That distinction matters when debugging: a 502 points at a process that is down or unreachable, a 504 points at one that is running but stuck, usually on a slow query, an external API call, or a lock.

Common causes

  • A slow database query, often one missing an index
  • An external API call the application makes with no timeout of its own
  • A request doing too much work synchronously — a large report or export
  • A deadlock or lock contention holding the request open
  • The upstream saturated, so requests queue behind others
  • A proxy timeout set lower than the application's own worst-case response time

If you're just trying to view the page

  1. Wait and retry — a slow query or a busy period often clears
  2. If it happens on one heavy action, such as generating a report, try a smaller date range or fewer items
  3. Check the status page; a 504 across a whole site means the operators already know
  4. Nothing on your side will speed the server up

If it's your site

  1. Find the slow operation before raising any timeout — a longer timeout turns a fast failure into a slow one
  2. Check the database slow query log and add the missing index; this is the single most common root cause
  3. Set explicit timeouts on every outbound HTTP call the application makes, so one slow dependency cannot consume a request slot indefinitely
  4. Move long work to a background job and return 202 with a status URL instead of holding the connection
  5. If you must raise the limit, raise `proxy_read_timeout` (Nginx) or the load balancer idle timeout — and remember the smallest timeout in the chain wins
  6. Watch for cascading failures: one slow dependency can saturate the pool and turn into site-wide 504s

Reference

Status code
504
Reason phrase
Gateway Timeout
Category
5xx — Server Error
Cacheable by default
No
Defined in
RFC 9110 §15.6.5

Common questions

What does HTTP 504 mean?
A proxy or gateway waited for the server behind it and gave up before an answer arrived. Like a 502, this comes from an intermediary reporting on the server behind it — but here the upstream was alive and simply too slow. The proxy hit its timeout and returned an error rather than waiting forever.
How do I fix a 504 error?
Wait and retry — a slow query or a busy period often clears
Is 504 a client error or a server error?
504 is in the 5xx range, which means server error. The request was acceptable but the server could not fulfil it, so retrying later can succeed.

Related pages

Sources

  1. Hypertext Transfer Protocol (HTTP) Status Code Registry — IANA
  2. RFC 9110: HTTP Semantics — IETF

How these figures are compiled and checked