Error 504 Gateway Timeout: how to identify where your website is slowing down
The 504 Gateway Timeout error means that an intermediary server, such as the Cloudflare proxy, waited for a response from another server but did not receive it in time. To resolve it, first determine whether the error affects all visitors or only your connection, whether it happens every time or only when performing a specific action, and which link in the chain was delayed: your application, PHP, DNS, or the intermediary itself.
If you’re only visiting someone else’s website, let its administrator know. The tests and changes in this guide require access to the site or hosting account.
What the error means and where the response may be delayed
When someone opens your website, the request passes through several servers in a chain: the browser, the Cloudflare proxy if the domain uses it, the web server, and the PHP process that runs your application. A 504 means that one of these intermediaries (the gateway) did not receive a response from the next link in the chain in time. A 502 Bad Gateway, on the other hand, means that the gateway received an invalid response: these are different failures, each with its own troubleshooting guide.
Each link in the chain has its own timeout. Cloudflare, for example, waits up to 125 seconds by default for a response from the origin server, then returns its own 524 code when that time expires; PHP and the web server have independent limits. That’s why the same symptom can come from different layers, and troubleshooting means identifying which one was delayed.
First, narrow down the problem
Save the full error message before changing any settings: the code and the page where it appears indicate where to start.
What you observe | Where to start |
|---|---|
Only your connection gets the 504 | Browser, cache, and local DNS. |
The error page displays the Cloudflare logo | The origin server did not respond in time: check the application. |
The code is 524, not 504 | This is Cloudflare’s own timeout (125 seconds by default). |
Everyone gets a 504 after a DNS change or migration | The domain’s A or AAAA record and proxy status. |
The 504 appears only when saving, importing, or running a task | PHP execution time and application performance. |
The 504 is intermittent and the site is slow | Account usage and PHP bottlenecks. |
The message says 503 or 508 | This is not a 504: it’s resource usage (see the dedicated guide below). |
Only your connection sees the 504
If the site works for other visitors, the problem is with your device, network, or DNS resolution—not the server.
Reload the page with a hard refresh:
F5orCtrl + F5on Windows,Cmd + Ron Mac.Try an incognito window. If it works there, a browser extension may be interfering.
Try a different browser, device, or connection, such as mobile data.
Clear your device’s DNS cache: on Windows, run
ipconfig /flushdns; on Mac, runsudo killall -HUP mDNSResponder.If you use a VPN, proxy, or your own firewall, temporarily disable it to compare the result.
The error page displays the Cloudflare logo
When the error page carries Cloudflare branding, the 504 was returned by the origin server: Cloudflare acted as an intermediary, and the problem is on the site’s side, usually because an application did not respond in time. If the page is not branded, Cloudflare itself may have generated the error.
In either case, copy the Ray ID and the exact time of the error: this information can be used to locate the request.
If the error only appears with the domain proxied through Cloudflare and the site responds normally when you open it without the proxy, try Pause Cloudflare on Site, which pauses the proxy and sends traffic directly to the server. Don’t use Development Mode as a test: it suspends caching but leaves the WAF, rules, and SSL/TLS active. Both controls are explained in how to temporarily disable Cloudflare.
If the code you see is 524, not 504, Cloudflare connected to your server, but the server did not return a response before the Proxy Read Timeout, which is 125 seconds by default (Cloudflare Enterprise zones can increase it). In this case, the application took longer than Cloudflare’s limit, so the sections of this guide about slow actions and PHP performance apply as well.
Everyone gets a 504 after changing DNS or migrating the site
A domain pointing to the wrong destination may return gateway errors instead of displaying the site.
Check that the domain’s
AorAAAArecord points to the expected value. Keep in mind that when the Cloudflare proxy is enabled, public queries may return Cloudflare IP addresses; see how to check a DNS change.If the value is incorrect, fix it before waiting: propagation won’t correct a misconfigured destination.
If the site uses Cloudflare, you can try Pause Cloudflare on Site, which pauses the proxy and sends traffic directly to the server, as explained in how to temporarily disable Cloudflare.
The 504 appears only when saving, importing, or running a task
Saving a large change, importing or exporting content, or running an update can exceed the available execution time even if the site opens normally. Note exactly which action triggers the error and how long it takes to fail: we need this information to locate the problem if you need to contact us.
Check the account’s Resource Usage in cPanel when the error occurs. Plan limits cause 503 and 508 errors, not a 504, but high usage can indicate whether the task is saturating resources; see resource usage and 503–508 errors.
If the task is a PHP process, the
max_execution_timelimit may be too low for the operation. You can adjust it in cPanel using the Select PHP Version tool, under the Options tab, as explained in how to change the PHP version and settings.To identify what is slowing down the application, use PHP X-Ray, which tracks slow plugins, database queries, and external calls; the server must have CloudLinux OS Shared Pro. See how to use PHP X-Ray for the procedure.
If the task is part of a WordPress plugin or theme, update it and try the action again; if the error started just after installing or updating that component, it’s the main suspect.
If the task still fails, send us the case with the information listed in the last section, including the exact action, date, and time when it occurs.
The 504 is intermittent and the site is slow
When the error appears intermittently and the site loads slowly, it’s best to measure before changing settings.
Check the account’s Resource Usage (Current Usage and DETAILS) in cPanel to see the account’s CPU, RAM, and process usage.
If the site is WordPress, follow the steps in what to do when you notice slow access and, to identify the component slowing down each page, use PHP X-Ray (requires CloudLinux OS Shared Pro), as explained in how to use PHP X-Ray.
If the 504 is concentrated on one URL or section of the site, note which ones: this pattern helps identify the delayed component.
Don’t make DNS, PHP, plugin, and security changes all at once to “make it go away.” Apply one change at a time and check the result: that way, you’ll know what fixed the problem and what made it worse. And don’t send passwords through public channels.
How to check that the issue is resolved
The check should repeat the same request that failed, from the connection or browser where the error occurred.
Open the affected URL and check that it loads without the error.
Repeat the action that triggered it, if the error occurred while saving or submitting something.
Try another page on the site to confirm that everything else is working.
Undo any temporary exceptions you no longer need, such as pausing Cloudflare, and note which change resolved the error.
Information we need to help you
If the error persists, open a support request through the customer portal and include the following information so we can locate the problem:
Domain and exact URL, without passwords or tokens in the parameters.
Screenshot or full text of the error, including the code shown.
Date, time, and time zone of the error, and the Ray ID if shown.
If you use Cloudflare, the output from the domain’s
/cdn-cgi/tracepath (open it in your browser and copy what it displays).Whether it affects all visitors, only one connection, only one action, or only traffic through Cloudflare.
The most recent change made to the site (DNS, PHP, plugins, themes) and the tests you’ve already tried.
You can also message us on WhatsApp or email [email protected]. Contact us from the account holder’s account or with an authorized contact.