HTTP 504 Gateway Timeout

Upstream server delays and gateway timeout errors

What the 504 Status Code Means

The HTTP 504 Gateway Timeout status code indicates that a server acting as a gateway or proxy did not receive a timely response from an upstream server while attempting to process the request.

In modern web infrastructure, requests often pass through multiple components such as CDNs, reverse proxies, load balancers, and API gateways. If one of these intermediary systems waits too long for a response from the backend service, it may return a 504 Gateway Timeout error to the client.

Common Causes of HTTP 504 Errors

Example of a 504 Response

HTTP/1.1 504 Gateway Timeout
Content-Type: text/html
Content-Length: 512

Unlike a 502 Bad Gateway, where an invalid response is received from an upstream server, a 504 response indicates that the gateway server did not receive any response within the configured timeout period.

Typical Infrastructure Scenario

A common request path in modern infrastructure may look like this:

Client → CDN → Reverse Proxy → Application Server → Database

If the application server or database fails to respond within the configured timeout window, the reverse proxy or gateway may return a 504 Gateway Timeout error to the client.

How Developers Diagnose 504 Errors

Diagnosing a 504 error often requires investigating multiple layers of the infrastructure to identify where response delays occur.

Related HTTP Status Codes

Summary

The HTTP 504 Gateway Timeout status code indicates that a gateway or proxy server waited too long for a response from an upstream service and terminated the request.

These errors are common in distributed architectures and usually indicate performance issues, network delays, or overloaded backend systems.