← all status codes

HTTP 504 Gateway Timeout

What a 504 Gateway Timeout response means, why it happens, and the fastest ways to fix it.

504
Gateway Timeout
5xx server error
Class

A proxy/load balancer timed out waiting for the upstream to respond — the request reached the backend but the backend didn't answer in time.

  • Slow database queries or N+1 patterns pushing responses past the proxy timeout.
  • Upstream deadlocked or starved of workers.
  • Proxy timeout set lower than the app's legitimate worst case.
  • Find the slow operation (APM/slow-query logs) and optimize it.
  • Align proxy read timeouts with realistic upstream latency.
  • Move long work to async jobs and return 202 + status polling instead.

Notes

HTTP status codes are defined in RFC 9110 (which replaced RFC 7231). The first digit is the class: 1xx informational, 2xx success, 3xx redirection, 4xx client error, 5xx server error.

Same class: 500 · 501 · 502 · 503 · 505 · 507

All codes: HTTP status code reference

Frequently asked questions

What does HTTP 504 mean?

HTTP 504 Gateway Timeout: A proxy/load balancer timed out waiting for the upstream to respond — the request reached the backend but the backend didn't answer in time.

How do I fix a 504 error?

Find the slow operation (APM/slow-query logs) and optimize it. Align proxy read timeouts with realistic upstream latency. Move long work to async jobs and return 202 + status polling instead.

Is a 504 my fault or the server's?

504 is a server error — something on the server side (or between the proxy and the app) failed.

Found this useful? 113 free, browser-only tools by Yuvrajsinh Jadav — an engineer who ships production AI systems. No account, nothing sent anywhere.