Products

Solutions

Resources

Search for API Security Tests

/

/

504 Gateway Timeout

504 Gateway Timeout

In this section you will learn about 504 Gateway Timeout, what is it, its components and examples.

In this section you will learn about 504 Gateway Timeout, what is it, its components and examples.

Luke Stephens

Luke Stephens

Luke Stephens

What is HTTP Status Code 504 Gateway Timeout?

The HTTP Status Code 504, titled "Gateway Timeout", is a server error response code. It signals that a server, acting as a gateway or proxy, did not receive a timely response from another server upstream, or some other auxiliary service it needed to access in order to complete the request. It's essentially a notice that one server did not receive a prompt response from another.

Understanding 504 Gateway Timeout

  • Upstream Delay: The 504 Gateway Timeout status code indicates that while the proxy or gateway server itself was reachable, it timed out waiting for another upstream server.

HTTP/1.1 504 Gateway Timeout
  • Network Delays: This error is often related to network issues, slow responses due to server overload, or distant upstream servers.

Why 504 Gateway Timeout?

The 504 Gateway Timeout error acts as an indicator when there's an issue with the server's upstream response, particularly in relation to the timely receipt of that response. It helps in pinpointing the bottleneck in a multi-server environment, suggesting where the delay or issue might be originating from.

Characteristics of 504 Gateway Timeout

  • Network Architecture Centric: This error is more prevalent in intricate network architectures, especially where servers function as gateways or proxies and rely on other servers to fulfill client requests.

  • Indication of Delay: Rather than a complete lack of communication or a server error, this status code specifically indicates a delay in response.

How does 504 Gateway Timeout Work?

  1. Client Sends a Request:

    The client issues a request to the server.

GET /external-data HTTP/1.1
Host: www.example.com
  1. Gateway Server Forwards the Request:

    The gateway or proxy server forwards the client's request to an upstream server for processing.

  2. Upstream Server Delays Response:

    For some reason—perhaps it's overloaded, down, or there are network issues—the upstream server doesn't respond in a timely manner.

  3. Gateway Server Responds with 504:

    After waiting and not receiving a timely response, the gateway server sends a 504 Gateway Timeout response to the client.

HTTP/1.1 504 Gateway Timeout
Content-Type: application/json

{
  "error": "The server, while acting as a gateway, did not receive a timely response from the upstream server."
}

Example of 504 Gateway Timeout

Requesting External Data:

GET /fetch-weather-data HTTP/1.1
Host: www.example.com

Response:

HTTP/1.1 504 Gateway Timeout
Content-Type: application/json

{
  "error": "Unable to fetch weather data in a timely manner. Please try again later."
}

In this illustration, a client attempts to fetch weather data, which relies on an external service. The gateway server, while trying to retrieve this data, doesn't get a prompt response, leading to a 504 Gateway Timeout.

Conclusion

The 504 Gateway Timeout status code is a pivotal indicator in the realm of networked servers, especially when dealing with multiple server dependencies. It provides clarity on where a potential delay or bottleneck might be, assisting server administrators and network engineers in diagnosing and rectifying issues. Grasping this status code and its implications is essential for maintaining smooth server interactions and ensuring a responsive web infrastructure.

On this page

Protect your APIs from attacks now

Protect your APIs from attacks now

Protect your APIs from attacks now

Explore more from Akto

Blog

Be updated about everything related to API Security, new API vulnerabilities, industry news and product updates.

Events

Browse and register for upcoming sessions or catch up on what you missed with exclusive recordings

CVE Database

Find out everything about latest API CVE in popular products

Test Library

Discover and find tests from Akto's 100+ API Security test library. Choose your template or add a new template to start your API Security testing.

Documentation

Check out Akto's product documentation for all information related to features and how to use them.