5xx Server error

HTTP 504 Gateway Timeout

A gateway or proxy did not get a response from the upstream server in time.

504 Gateway Timeout means a gateway or proxy did not get a response from the upstream server in time.

HTTP/1.1 504 Gateway Timeout

Common causes

  • A slow database query or external API call that keeps the application busy past the proxy's timeout.
  • The upstream server is overloaded or unreachable.
  • Timeouts that are shorter at the proxy than at the application.

How to fix it

  • Find the slow request in the application logs and make it faster, or move it to a background job.
  • Raise the proxy timeout (for example proxy_read_timeout in nginx) only if the work is legitimately long.
  • For long operations, answer 202 Accepted and let the client poll.

Related status codes

Other status codes

1xx Informational

2xx Success

3xx Redirection

5xx Server error

Search all HTTP status codes