HTTP 504 Gateway Timeout

An upstream server did not respond in time. The failure is in the chain behind the endpoint, not at the endpoint itself.

Defined in RFC 9110 §15.6.5 — 504 Gateway Timeout · MDN reference

Where you meet HTTP 504 in production

A gateway or load balancer giving up on an upstream that did not answer in time — most often a slow query, a saturated pool, or a downstream call with no timeout of its own.

Why you would test it

Test what your own timeout does when it is shorter than the gateway's — you will get a client-side abort rather than the 504, and your logs will disagree with theirs.

What your client should do about a 504

The critical thing about a 504 is that the work may still be running. The gateway stopped waiting; the upstream did not necessarily stop working. Retrying a write after a 504 can duplicate it, so make it idempotent or check the state before retrying. Set a client timeout shorter than the gateway's so you keep control of the deadline.

504 versus the codes it gets confused with

Endpoints that return 504

1 endpoint in this playground answers with 504. Every one is free, needs no signup, and can be called from the browser or with curl.

Questions about HTTP 504

Is a 504 the client's fault?
Rarely — but a client that retries aggressively into a struggling upstream makes it considerably worse.
Did my request go through?
A 504 cannot tell you. That ambiguity is the reason idempotency keys exist.

Other server error codes

All HTTP status codes · All 39 mock REST APIs · Getting started guide

Last updated