The page hangs for a long time — often thirty or sixty seconds — and then returns “504 Gateway Timeout”. It frequently hits one specific page, export, or admin action rather than the whole site.
What it actually means
A 504 is a stopwatch, not a crash. One server asked another for your page, waited the maximum time it was configured to wait, and gave up. The work may even have finished afterward, unseen, with nobody left to receive it.
That makes 504 the most diagnosable of the server errors, because it points straight at slowness. Something in that request is taking longer than the limit allows, and the fix is to find it and either speed it up or stop doing it during a page load.
What usually causes it
Most likely first.
- 1
A slow database query
An unindexed table, a bloated options table, or a report pulling years of rows. The usual suspect behind timeouts on one specific page.
- 2
An external API call with no timeout
Your site calls a payment gateway, shipping service, or feed that is having a bad day, and waits patiently until the gateway above it gives up.
- 3
A heavy import, export, or backup
Long-running jobs run through a web request instead of a background queue. They exceed the limit almost by definition as data grows.
- 4
Too little server capacity
Requests queue behind other requests. Each one is fine on its own; together they exceed the wait.
- 5
A crawler or bot hitting expensive pages
Faceted search and filtered archives can generate thousands of costly URLs that a bot will happily walk through until everything slows.
How to fix it
Work through these in order. Take a backup before you change anything.
Step 1 — Note exactly which URL times out
One page or all pages? An admin action or a public page? A 504 confined to one URL is a slow-code problem; a site-wide 504 is usually capacity.
Step 2 — Check the slow query log
Enable it if it is not already on. Queries taking multiple seconds will be sitting at the top, and they are almost always the cause.
Step 3 — Disable plugins around the failing action
If the timeout is on a specific action, disable suspect plugins and retry. Backup, security-scan, and reporting plugins are common culprits.
Step 4 — Move long jobs to the background
Imports, exports, and syncs should run on a queue or cron, not inside a page load. This is the durable fix rather than raising the limit again.
Step 5 — Raise the timeout only as a stopgap
Increasing the gateway and PHP execution limits buys room, but a page that needs sixty seconds is a page nobody is going to wait for anyway.
When to stop and call someone
Call someone when the timeout is on checkout, a form, or anything that takes money — every 504 there is a lost order. Also worth calling when the slow query log names something in your database rather than a plugin you can simply switch off.
Frequently asked
It means one server waited for another to produce your page and ran out of patience. Nothing crashed — the request simply took longer than the configured limit, so the connection was closed and an error returned in its place.
A 502 means the upstream server returned an invalid response or none at all; a 504 means it returned nothing in time. In practice, 502 points at a crashed or misconfigured service, and 504 points at something slow.
Because that page is doing something expensive the others are not — usually a slow database query, a large export, or an external API call with no timeout. A 504 confined to a single URL is the easiest kind to trace.
It hides it. Raising the gateway and PHP limits lets the request finish, but a page that needs a minute to load has already lost the visitor. The durable fix is to make the work faster or move it to a background job.
Directly, if it happens at checkout or on a form. The customer sees a hang and then an error, assumes the payment may have gone through, and usually leaves rather than trying again. Timeouts on revenue paths deserve immediate attention.
If you’d rather not
We do this work every week. These are the services that cover it.
- Site Speed & Core Web VitalsA slow site loses the customer before they see your offer. We fix what makes pages crawl — heavy images, bloated scripts, blocked rendering — and prove it with numbers.
- Fixing Broken WebsitesSite down, hacked, or falling apart? We diagnose it fast, fix what's broken, and tell you straight how to keep it from happening again.
- Custom Web SolutionsBuild the web system your business actually needs. We design custom web systems around your offer, your team, your data, and the way buyers move from interest to action.
See exactly what’s holding your website back.
Get a free audit of your site — speed, SEO, mobile, and security — with the fixes that matter most, delivered as a PDF to your inbox.