504 Error

A 504 Gateway Timeout error is a webserver’s code for:

“I reached out to the upstream server for you, but it took too long to answer and timed out.”

A 504 Gateway Timeout error indicates that the server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request.

While a 502 error means the upstream server sent a broken or invalid answer, a 504 error means the upstream server didn’t answer at all within the allotted timeout window.

Determining why

  • The backend server is overloaded with traffic and cannot keep up.
  • A database query or complex backend calculation is hanging or taking minutes to complete.
  • Network latency or packet drops between the proxy and the upstream server.

Steps you could possibly take:

  • Wait and retry - Refresh the page after a few moments. If the server was temporarily spiked, the load may subside.
  • If you are the website owner or server administrator:
    • Increase proxy timeout directives (such as proxy_read_timeout in nginx or Timeout in Apache) if requests legitimately require extended compute time.
    • Optimize slow SQL queries and add database indexes.
    • Offload long-running operations (like bulk emails or video transcoding) to background worker queues rather than processing them synchronously inside web requests.

Source: RFC 9110 Section 15.6.5 (HTTP Semantics)