HTTP Status Codes / 5xx HTTP Status Codes / HTTP 504

504 Gateway Timeout

This is an educational reference page about HTTP 504 Gateway Timeout. The page itself is served as 200 OK so it can be indexed as HTTP documentation.

The server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to complete the request.

Specification

Registered in the IANA HTTP Status Code Registry as Gateway Timeout. Defined in RFC 9110, Section 15.6.5.

What it means

HTTP 504 Gateway Timeout means a gateway or proxy waited for an upstream server and gave up before it answered. The upstream request may still be running, and may still succeed, after the client already received the 504.

When to use it

Common causes

How to fix it

Examples

Slow report behind a proxy

GET /reports/annual?year=2025 HTTP/1.1
Host: app.example.com

HTTP/1.1 504 Gateway Time-out
Server: nginx
Content-Type: text/html

<html><head><title>504 Gateway Time-out</title></head>...

Common mistakes

Developer notes

504 leaves the result unknown, not failed. Design writes to be safely retryable, with an idempotency key or a client-generated ID, so clients can retry after a timeout without creating duplicates.

Questions

What does HTTP 504 Gateway Timeout mean?

HTTP 504 means a gateway or proxy did not get a response from the upstream server in time.

Did my request fail if I got a 504?

Not necessarily. The upstream server may still finish the request. Check before retrying a write.

How do I fix 504 Gateway Timeout?

Find out why the upstream is slow and fix that first. Move long work to a background job, and raise proxy timeouts only when the wait is expected.

See also

Header and content rules

RFC 9110 adds no header or content rule specific to 504. The 5xx class rules also apply. See 504 in the response obligations table.

Related comparisons

5xx server error – the server failed to fulfill an apparently valid request


HTTP status code lookup
REST API status code chooser
cURL command generator
By Ping Now, a website/API/service uptime monitor
Data from Wikipedia