HTTP 504 Gateway Timeout — What It Means

What HTTP status code 504 Gateway Timeout means, when servers return it, and how to handle it correctly.

Published September 26, 2026

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

What it means

The backend is slow or hanging; the proxy gave up waiting.

Common causes: Slow database queries or API calls; Proxy timeout lower than the job; Overloaded upstream.

On the wire

GET /report HTTP/1.1
HTTP/1.1 504 Gateway Timeout
Server: nginx
A typical 504 exchange.

Practical examples

Test it from the shell

curl -i https://example.com/path   # look for HTTP 504

Handling 504 in code or config

proxy_read_timeout 120s;

How to fix it

Optimise the slow operation; Raise proxy timeouts carefully; Move long jobs to a queue.

1. Reproduce: curl -i <url>
2. Confirm the status is 504
3. Apply the fix above and re-test

Common mistakes

  • Optimise the slow operation
  • Raise proxy timeouts carefully
  • Ignoring the response headers that explain the details.

Key takeaways

  • 504 means Gateway Timeout.
  • HTTP 504 Gateway Timeout means a gateway or proxy did not get a response from the upstream server in time.
  • Read the response headers and logs for the exact cause.

FAQ

How do I debug a 504?

Check upstream latency and logs; time the backend directly.

Is 504 a client or server error?

It is a server error status code, in the 5xx class.

More HTTP articles