Server Error · 5xx

504 Gateway Timeout

A gateway or proxy did not receive a response from an upstream server in time.

What 504 Gateway Timeout means

504 Gateway Timeout means the proxy or CDN waited for the origin to respond and gave up. Common timeout values: Cloudflare 100s on free, Nginx 60s default, AWS ALB 60s default, API Gateway 29s for HTTP and 30s for WebSocket. 504s usually mean the origin is doing too much work per request: a slow database query, an unindexed scan, an external API call that did not have its own timeout.

When servers should return it: A proxy returns 504 when the origin does not respond within the configured timeout. Origin operators see 504 as "we are too slow".

Common causes

How to fix 504 Gateway Timeout

Example response

HTTP/2 504
server: cloudflare
content-type: text/html
<html><body>504 Gateway Timeout</body></html>

Related status codes

Frequently Asked Questions

504 vs 408?
408 = the client did not finish sending the request in time. 504 = the upstream did not finish sending the response in time.
Why does my request work locally but 504 in production?
Production usually has tighter timeouts (Cloudflare 100s, ALB 60s, API Gateway 29s). Local has no proxy and no timeout. Profile the slow request and either speed it up or move to async.
Defined in: RFC 9110 · Class: 5xx Server Error

More references

For a one-page reference of all HTTP status codes, see the HTTP cheat sheet. For testing API responses, try the API Tester tool. For inspecting responses on the command line, the curl cheat sheet covers the most common flags.