All HTTP status codes
5xx Server Error
RFC 9110

504 Gateway Timeout

The gateway/proxy did not receive a timely response from the upstream server.

What it means

HTTP 504 Gateway Timeout indicates that a server acting as a gateway or proxy did not receive a response from the upstream server within the time it was prepared to wait.

When it's used

Reverse proxies when the backend takes longer to respond than the proxy timeout allows.

Common causes
  • Slow database query in backend
  • Backend stuck in infinite loop
  • Backend waiting on a slow third-party API
  • Proxy timeout set too aggressively
How to fix it
  • Profile and optimize slow backend operations
  • Increase proxy timeout if backend is legitimately slow
  • Implement async processing with 202 Accepted for long jobs
  • Add timeouts to third-party calls in backend code
Example response
HTTP/1.1 504 Gateway Timeout
Content-Type: text/html

<h1>504 Gateway Timeout</h1>
SEO impact

Hurts crawl budget and can lead to deindexing if persistent. Optimize backend performance.