You load a page, the browser hangs for what feels like forever, and then: 504 Gateway Timeout. Unlike a quick "not found," a 504 means something waited, and waited, and finally gave up. That single detail tells you a lot about what's wrong — and how to fix it. Below is what actually causes a 504 and 8 ways to clear it, covering both the visitor who just wants the page to load and the site owner staring at the error in their logs.

What a 504 Gateway Timeout actually means

Most modern websites don't answer requests directly. Your request passes through a gateway — a proxy, load balancer, or CDN like Nginx or Cloudflare — which forwards it to the real "origin" server behind the scenes. A 504 happens when that gateway forwards your request but the origin doesn't reply within the allowed time, so the gateway returns a timeout instead of a page.

This is what separates 504 from its close cousin 502. A 502 Bad Gateway means the origin sent back an invalid response; a 504 Gateway Timeout means it sent back nothing in time. Both are server-side errors, so as a visitor your options are limited — but a few are still worth trying. Our guide on what HTTP status codes mean shows how 504 fits alongside 500, 502, and 503.

Why does a 504 Gateway Timeout happen?

The error always comes down to the origin being too slow to answer. Common reasons:

  • The origin server is overloaded — too much traffic, not enough CPU or memory.
  • A long-running script or database query takes longer than the gateway's timeout limit allows.
  • Network problems between the proxy and the origin server.
  • A CDN or firewall waiting on an origin that never responds.
  • Undersized timeout settings on the proxy, cutting off legitimately slow requests.

8 ways to fix a 504 Gateway Timeout

1. Wait a minute and refresh

Most 504s are caused by a brief overload — a traffic spike or a slow query that clears on its own. Wait 30–60 seconds and reload before doing anything else.

2. Confirm it's down for everyone

Run the site through our live website down checker. If our server also gets a 504, the site is genuinely struggling and waiting is your only real option. If our server loads it fine, the problem may be a cached error or something on your network. Our guide on whether a site is down for everyone or just you helps you read the result.

3. Hard-reload and clear your cache

A cached 504 page can keep showing even after the site recovers. Do a hard reload (Ctrl + F5, or Cmd + Shift + R on Mac), or open the page in an incognito window to bypass your cache and extensions.

4. Flush your DNS and try a different resolver

Occasionally the timeout is tied to a stale DNS entry or a slow resolver. Flush your DNS cache and switch to 1.1.1.1 or 8.8.8.8 — our step-by-step DNS flush guide covers every platform.

5. Disable your VPN or proxy

If you're routing through a VPN or proxy, it may be adding the delay that pushes the request past the timeout. Turn it off and reload to rule it out.

6. (Owners) Increase your gateway timeout limits

If it's your site, the fastest relief is often raising the timeout thresholds so slow-but-valid requests aren't cut off. In Nginx, adjust proxy_read_timeout and fastcgi_read_timeout; in PHP, check max_execution_time. This treats the symptom while you address the real cause in the next steps.

7. (Owners) Find and fix what's slow

Read your error logs (for example /var/log/nginx/error.log) for "upstream timed out" messages, then hunt down the slow request behind them — usually an unoptimized database query, a heavy API call, or a resource-starved server. You can measure how long your server takes to respond with our free site speed (TTFB) test; a very high time-to-first-byte confirms the origin is the bottleneck. For a fuller breakdown, see our explainer on why a website loads slowly.

8. (Owners) Check your CDN, firewall, and monitor for it

If you use Cloudflare, a timeout can surface as a 524 rather than a 504 — our Cloudflare errors guide explains those variants and who's at fault. Make sure no firewall rule is delaying the origin connection. Then set up free uptime monitoring so we email you the moment your site starts timing out — before your visitors ever see a 504.

How 504 differs from 502 and 524

It's easy to mix these up, so here's the quick version: 502 Bad Gateway means the origin gave a broken reply, 504 Gateway Timeout means it gave no reply in time, and Cloudflare's 524 is specifically a timeout at Cloudflare's edge. If you're actually seeing a 502, our dedicated guide on fixing 502 Bad Gateway walks through that one in full.

The bottom line

A 504 Gateway Timeout means a gateway server waited too long for the backend and gave up — a server-side slowness problem, not something wrong with your device. As a visitor, refresh, confirm it's down for everyone, and clear your cache; beyond that, you wait. As an owner, raise your timeout limits for quick relief, then fix the slow query or overloaded server behind it — and add monitoring so the next 504 reaches you first.