504 Gateway Timeout
A proxy gave up waiting for the upstream server to answer. The upstream may still be working on the request.
At a glance
- Status code
- 504 Gateway Timeout
- Class
- 5xx, server error, the request looked fine and the server failed
- Defined in
- RFC 9110
- Cacheable by default
- by explicit headers only
- Response body
- Usually a generic timeout page.
In detail
Unlike 502, the upstream did not fail, it was simply too slow for the gateway's patience. The work may complete after the client has already been told it failed.
Timeouts should decrease as you move outward: the gateway should wait longer than the origin, or the origin's own timeout never fires.
Retrying a 504 on a non-idempotent request is dangerous. The original may have succeeded after the timeout, so the retry duplicates the work.
Examples
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html
<h1>Gateway timeout</h1>Things that catch people out
- A 504 at a suspiciously round number of seconds is a configured limit, not a coincidence. Find the component that owns that number.
- Long-running requests should return 202 with a job URL instead of holding a connection open long enough to hit a gateway limit.
Try it: HTTP Request Builder
Build a request with any method, headers and body, send it, and read the status line the server returns.
HTTP Request Builder
LOCAL · Browser-OnlyBuild and test HTTP requests with custom headers and body
Authentication
Headers
Generate Code
curl -X GET 'https://api.example.com/endpoint' \
-H 'Content-Type: application/json'Showing a sample URL. Enter your endpoint above to update the snippet.
Related HTTP status codes
All http status codes →502 Bad Gateway
A proxy or load balancer got an invalid response from the upstream server it was relaying to. The failure is behind the thing that answered you.
503 Service Unavailable
The server is temporarily unable to handle the request, because it is overloaded or deliberately down for maintenance. The condition is expected to clear.
408 Request Timeout
The server gave up waiting for the client to finish sending the request and closed the idle connection.
505 HTTP Version Not Supported
The server refuses the major HTTP version used in the request line.
506 Variant Also Negotiates
A server configuration error in transparent content negotiation: a chosen variant is itself configured to negotiate, creating a loop.
507 Insufficient Storage
The server cannot store the representation needed to complete the request, because it is out of space.
Tools for this
- HTTP Request Builder Free online HTTP request builder - build and test HTTP requests with custom headers and body
- HTTP Headers Checker Free online HTTP headers checker - view HTTP response headers for any URL