504 Gateway Timeout: your server took too long and the visitor gave up
Last reviewed
The service in front of your site stopped waiting for an answer.
A 504 Gateway Timeout is the HTTP status a CDN, proxy or load balancer returns when the server behind it does not answer in time. The server may be running but stuck on slow code, a slow database or an outside service that never replied. Visitors get an error after a long wait, and the fix is finding what makes the server that slow.
Why a 504 Gateway Timeout error costs you customers
A 504 costs twice: the visitor waits, then gets nothing. It tends to appear on the heaviest pages first, such as search, booking or checkout, which are often the pages closest to a sale. Because it depends on load, it can be invisible on a quiet morning and constant at the busiest hour.
What usually causes a 504 Gateway Timeout error
- A slow database query, often on a page that searches or filters
- An outside service the page waits on, such as a booking or payment system, not answering
- The server is overloaded and requests queue up
- A plugin or script that runs a long job on every page load
- Network problems between the CDN or proxy and the server
How to check for a 504 Gateway Timeout error yourself
- Note which pages show the 504. If it is only a search, booking or checkout page, that page's own work is the slow part.
- Try the same page at a quiet time and a busy time. A 504 that only appears when busy points to the server running out of capacity.
- Check the status pages of outside services your site relies on, such as a booking system or payment provider.
- Ask your host whether the account shows slow database queries or processes hitting time limits.
How to fix a 504 Gateway Timeout error
- Your web person finds the slow step using the server logs or a performance tool, starting with the pages that show the 504.
- Your web person speeds up or caches the slow database query, or moves a long job off the page load.
- Your web person adds a short time limit on calls to outside services, so one slow service cannot stall the whole page.
- Your host adds capacity if the server is simply too small for the traffic it gets.
- After the fix, your web person sets up alerts on slow responses, so the next slowdown is caught before it becomes a timeout.
How Prsona catches a 504 Gateway Timeout error
On each scheduled scan Prsona requests your homepage and the pages it can reach. A homepage that times out behind your gateway is reported as the site being down, and an inner page that times out is listed with its address, so slow pages are named rather than guessed.
Prsona looks for a 504 Gateway Timeout error as part of uptime monitoring and broken page detection.
See which pages stall, with the address of each one.
Questions about a 504 Gateway Timeout error
What is the difference between a 502 and a 504?
A 502 means the gateway got a broken or empty reply from your server. A 504 means it got no reply in time at all. Both start on your side, but a 504 usually points to something slow rather than something crashed.
Can a 504 be caused by the CDN itself?
Rarely. The CDN reports the timeout, but the wait almost always happens on your server or a service it calls. Fixing the slow step on your server is what clears it.