Skip to content
EN
Get Started

504 Gateway Timeout

504 Gateway Timeout is an HTTP error sent by a gateway or proxy when an upstream server doesn't respond in time, preventing it from completing the request.

Table of Contents (8 sections)

What a 504 means

A 504 comes from a server acting as a gateway, such as a CDN, reverse proxy or load balancer. It forwarded your request to an upstream server but didn’t receive the response within its time limit.

HTTP/1.1 504 Gateway Timeout

The sender could be infrastructure in front of the website or a forward proxy you’re using. Headers such as Server and Via may identify the gateway, though some services remove or replace them. Unlike a connection timeout, a 504 is an HTTP response that reached your client.

Common causes

  • An overloaded upstream server. The application has more work than it can finish before the gateway’s deadline.
  • Slow backend work. Database queries, API calls or file processing take too long.
  • Network or DNS trouble. The gateway can’t reliably connect to or resolve the upstream service.
  • A proxy route problem. If requests fail only through a proxy, its route or exit server may be slow or unavailable.

How to fix a 504

  1. Retry safe requests after a delay. Use limited retries with exponential backoff. Don’t blindly retry a payment or other POST request because the upstream server may have completed it after the gateway stopped waiting.
  2. Compare direct and proxied requests. If the direct request works but the proxied one fails, test another healthy proxy route. If both fail, the problem is likely on the website side.
  3. Reduce request pressure. Lower concurrency and request frequency. Large bursts can overload the site or gateway.
  4. Check upstream services if you operate the site. Review application logs, database performance, DNS resolution and gateway timeout settings. Increasing the timeout can hide a slow backend, so find the delay first.

504 vs 502 vs 503

Code Sent by Meaning
504 Gateway Timeout Gateway or proxy Upstream response took too long
502 Bad Gateway Gateway or proxy Upstream returned an invalid response
503 Service Unavailable Server or gateway Service is temporarily unable to respond

FAQ

Is a 504 Gateway Timeout caused by my proxy?

It can be. Compare the same request with and without the proxy. A failure on both paths usually points to the website’s gateway or upstream server.

Will changing my proxy IP fix a 504 error?

Only if the proxy route or exit server caused the delay. Changing IPs won’t fix an overloaded website, slow database or unavailable upstream API.

How long should I wait before retrying a 504?

Wait a few seconds, then retry a safe request with increasing delays. Honor Retry-After if the response includes it and stop after a limited number of attempts.

Related Terms

View All Terms