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
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.
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.
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.
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.
GET https://funapi.dev/api/protocol/v1/gateway-timeout — Always, after ~3 seconds. Pair it with a 2s client timeout. (Protocol Lab API) Open & run this endpointAll HTTP status codes · All 39 mock REST APIs · Getting started guide
Last updated