504 Gateway Timeout

A gateway or proxy did not receive a timely response from the upstream server it needed to complete the request.

Status

HTTP/1.1 504 Gateway Timeout

Details

504 means the upstream was reachable but too slow. The intermediary waited out its configured timeout and gave up. Unlike 502, a connection was established: the work simply did not finish in time.

It usually points at one slow dependency rather than a broken service. A single unindexed query, a blocking external API call, or a lock contention hotspot will produce 504s under load while everything else looks healthy.

Common causes

How to fix it

As the client

As the server

Examples

GET /api/reports/annual HTTP/1.1
Host: api.example.com

HTTP/1.1 504 Gateway Timeout
Content-Type: text/html; charset=utf-8
Server: nginx

Notes for proxy users

Timeouts through a proxy stack on top of each other: your client timeout, the proxy's, and the target's. When you see 504s in automation, compare the same request made directly. If both are slow, the target is the bottleneck and raising your own timeout is the only useful change.

Specifications

RFC 9110 §15.6.5

See also