HTTPREF
← Back to status codes

HTTP Status Code

504 Gateway Timeout

Server Error

The server did not receive a response from an upstream server in time.

HTTP status code reference, response example, common causes, fixes, and related status codes.

What does HTTP 504 Gateway Timeout mean?

HTTP 504 Gateway Timeout is a status code sent by a server to indicate the result of an HTTP request.

Status codes help browsers, APIs, apps, and backend systems understand whether a request succeeded, failed, was redirected, or needs additional action.

In practice, HTTP 504 Gateway Timeout usually appears when a server responds under specific request, validation, permission, or infrastructure conditions.

Response example

HTTP/1.1 504 Gateway Timeout

HTTP example

HTTP/1.1 504 Gateway Timeout

Common causes

  • Slow backend service
  • Upstream timeout
  • Network issue between gateway and backend

How to fix it

  • Check backend response times
  • Increase timeout if appropriate
  • Optimize slow upstream services

Common mistakes

  • Assuming the status code alone explains the full backend issue
  • Ignoring related response headers that add important context
  • Treating temporary errors as permanent failures
  • Retrying too aggressively without checking the cause
  • Debugging the frontend only when the problem is server-side

How browsers and APIs use it

Browsers, APIs, and backend services use HTTP status codes to understand the outcome of a request. Depending on the status code, an application may render content, retry a request, redirect the user, show an error, or trigger a different flow in the client or server.

Developer note

HTTP 504 often points to a slow dependency rather than a direct crash. Check databases, third-party APIs, and internal service latency.

Client-side example

if (response.status === 504) {
  console.log("Gateway timeout");
}

Related status codes