Guides
504 Gateway Timeout: What It Means & How to Fix It
On this page
A 504 Gateway Timeout means a server that was acting as a gateway or proxy waited for a response from an upstream server and didn’t get one in time — so it gave up. Unlike a 404 or a 500, a 504 is almost always about waiting: something behind the front-facing server was too slow. It’s a server-side (5xx) error, so it’s not your visitors’ fault — and it’s usually fixable once you find what’s slow.
What does 504 Gateway Timeout actually mean?
Modern sites rarely have one server. A front-facing server — a reverse proxy like Nginx, a CDN like Cloudflare, or a load balancer — receives the request and passes it to an upstream server (your app, PHP, a database-backed backend) to do the real work. If that upstream doesn’t answer within the gateway’s timeout window, the gateway returns a 504 to the visitor.
So a 504 is really the front server saying: “I asked the backend and it never replied in time.” The problem is upstream, not usually the gateway itself.
What causes a 504 error?
The common culprits, roughly in order:
- An overloaded or slow backend. The server doing the work is under-resourced or busy, so it can’t respond in time. The most frequent real cause.
- Slow database queries or inefficient code. A single unindexed query or a heavy operation can blow past the timeout.
- A slow plugin, theme, or script (on CMS sites like WordPress) that hangs the request.
- CDN, proxy, or firewall misconfiguration — the layer in front isn’t passing requests along efficiently, or its timeout is shorter than the work takes.
- Network problems between servers — the gateway can’t reach the upstream reliably.
- A traffic spike overwhelming capacity.
How to fix a 504 Gateway Timeout
Work from most-likely to least:
- Check if it’s you or the site. If it’s a site you visit, try reloading in a minute, a different network, or incognito — transient 504s often clear on their own. If it persists across everyone, it’s server-side.
- Find the slow backend. On your own site, check server load, backend response times, and error logs during the 504s. This is where the real fix almost always lives.
- Optimize the slow work. Add database indexes, fix slow queries, disable or replace a hanging plugin, and cache expensive responses so they don’t recompute on every request.
- Raise (or align) timeouts — carefully. Increasing the gateway’s timeout (e.g. Nginx
proxy_read_timeout, or PHPmax_execution_time) can stop the 504, but it only hides a slow backend. Fix the speed first; adjust timeouts second, and keep them consistent across CDN → gateway → backend. - Add capacity if it’s load. If 504s spike with traffic, you need more server resources, better caching, or moving long jobs to a background queue so requests return fast.
- Check your CDN/proxy config. Make sure the layer in front is healthy and its timeout isn’t shorter than legitimate work requires.
Does a 504 hurt SEO?
Occasional 504s won’t hurt rankings — Googlebot will simply retry later. But persistent 504s are a real problem: if Google repeatedly can’t load your pages, it crawls less and can eventually drop pages that stay unreachable. And a site slow enough to throw 504s is failing users too, which affects conversions and Core Web Vitals. So treat frequent 504s as an urgent performance issue, part of the technical foundation covered in technical SEO in the AI era. (For its client-side cousin — the client hanging up early — see HTTP 499.)
The bottom line
A 504 Gateway Timeout is a “the backend was too slow” error, not a broken-page error. Reload to rule out a blip, then hunt the slowness — server load, slow queries, a hanging plugin — and fix that. Raising timeouts can mask it, but real 504 prevention is a fast, well-resourced backend.
If clear technical answers are useful to you, I send them occasionally — subscribe below, and grab the free GEO Starter Checklist.
Frequently asked questions
What does 504 Gateway Timeout mean?
It means a server acting as a gateway or proxy (like Nginx, a CDN, or a load balancer) did not receive a response from the upstream server in time, so it returned a 504. It is a server-side error about waiting — something behind the front server was too slow.
How do I fix a 504 gateway timeout error?
Find and fix the slow upstream: check server load and backend response times, optimize slow database queries and inefficient code, disable hanging plugins, and cache expensive responses. Raising gateway timeouts can stop the error but only masks a slow backend — fix the speed first.
Is a 504 error my fault as a visitor?
No. A 504 is a server-side (5xx) error caused by the site's infrastructure being too slow, not by anything you did. Reloading after a minute, switching networks, or trying incognito can help with transient 504s, but a persistent one is the site owner's to fix.
Does a 504 error affect SEO?
Occasional 504s do not — Googlebot retries later. Persistent 504s do: if Google repeatedly cannot load your pages it crawls less and may drop unreachable pages, and the underlying slowness also hurts user experience and Core Web Vitals. Frequent 504s are an urgent performance fix.