504 Gateway Timeout

A gateway or proxy did not receive a timely response from the upstream server.

Last updated . How this page is checked.

Status code504
Status textGateway Timeout
Category5xx Server Error
Response has bodyUsually
SpecificationRFC 9110

What does 504 Gateway Timeout mean?

A gateway or proxy did not receive a timely response from the upstream server. It belongs to the 5xx Server Error class, which means the server failed to fulfil an apparently valid request. The problem is on the server side.

When do APIs return 504?

A slow database query, a long-running operation, or an upstream dependency that hung.

How to fix a 504 Gateway Timeout

The request may still be processing on the server despite the timeout — be careful about blindly retrying non-idempotent operations, or you may create duplicates. For genuinely slow work, the API should move to an asynchronous pattern returning 202.

Reproduce a 504 response

The fastest way to understand a status code is to trigger one and read the full response. Open the API tester and send a request to https://httpbin.org/status/504 — you will see the 504 status along with every response header the server sent. Comparing those headers against a working request is often what reveals the cause.

When you are debugging a real endpoint, check the response headers as carefully as the body, and confirm you are using the right HTTP method for the operation.

Related 5xx status codes

504 Gateway Timeout FAQ

What causes a 504 Gateway Timeout?

A proxy or load balancer waited for the server behind it and gave up. The upstream is usually running but slow: a long database query, a slow third-party call, or a timeout on the proxy that is shorter than the work takes.

What is the difference between 504 and 408?

504 means a gateway timed out waiting for an upstream server. 408 Request Timeout means the server timed out waiting for the client to finish sending the request.

Did my request go through if I got a 504?

Possibly. The gateway stopped waiting, but the upstream server may have carried on and completed the work. Check the result before repeating a request that is not idempotent, such as a payment.

See also

  • 502 Bad Gateway — A server acting as a gateway or proxy received an invalid response from the upstream server.
  • 503 Service Unavailable — The server is temporarily unable to handle the request.
  • 524 A Timeout Occurred — Cloudflare connected to the origin server, but the origin took too long to send a response.

References