A 504 Gateway Timeout means that the server forwarding your request does not receive a timely response from the backend server. This is usually caused by a slow script, an overloaded database, a misconfigured proxy, or a plugin that gets stuck. In this article you’ll learn how to find the cause and which steps you can take to permanently resolve the error.
What exactly is a 504 Gateway Timeout
In many hosting environments there is an intermediate layer between the visitor and your website: a reverse proxy, load balancer, or caching layer. This layer forwards the request to the web server or application that actually builds the page. If this takes too long, the intermediate layer returns a 504 instead of continuing to wait. The difference with a 500 error is important: with a 504 there is no error message from your application itself, but simply no response within the set time.
Common causes
A 504 can have multiple causes, often a combination of them:
- Slow database queries that keep hanging, for example due to missing indexes or too large a dataset.
- Plugins or themes that make heavy external requests (APIs, feeds) that don’t respond in time.
- Timeout settings that are too low in PHP, the web server, or a proxy/CDN in front of it.
- Overloaded server due to peak load, cronjobs running simultaneously, or insufficient resources.
- Misconfigured reverse proxy between CDN and origin, causing requests to be forwarded incorrectly.
- DNS or network issues causing the backend server to be unreachable or too slow.
Step-by-step plan to resolve the error
Check the error logs
View the error logs of your hosting environment. In Plesk you can find these under the website settings at ‘Log Files’. Here you can often see which script or request is getting stuck.
Temporarily disable plugins and themes
For WordPress, disable recently added plugins one by one to determine whether a specific plugin is causing the slow response.
Check the database
Use phpMyAdmin or a command line tool to detect slow queries. Optimize tables and add indexes where necessary.
Increase or check timeout settings
Adjust the timeout values of PHP and the web server if scripts structurally need more time, but first try to find the underlying cause rather than using this as a permanent solution.
Check external connections
If your website depends on external APIs, test whether these services themselves respond slowly. A slow external source can cause the entire page to get stuck.
Contact support
If you can’t figure it out, contact your hosting provider. They can check server load and network connections that you cannot see yourself.
Preventing a 504 in the future
Prevention is better than cure. Make sure you have an up-to-date backup before making changes, so you can always fall back on a working version. Keep plugins, themes, and the CMS core up to date, and monitor your website’s uptime so you’re notified immediately if something goes wrong. An environment with sufficient resources and a well-configured server, such as you’ll find with webhosting with modern server software, prevents slow scripts from immediately leading to a complete timeout. If you’re still considering switching providers after repeated issues, read how switching to Tandata works.
Frequently Asked Questions
Is a 504 error the same as a 502 error?
No. A 502 Bad Gateway means the proxy received an invalid response, while a 504 means no response arrived at all within the set time.
Can I resolve a 504 error myself without technical knowledge?
Some of the steps, such as disabling plugins, you can do yourself. For deeper server issues it’s wise to contact your hosting provider.
Does a 504 also occur with email or only with websites?
This error specifically occurs with web requests via HTTP. Email problems manifest differently, for example as bounce messages.
Conclusion
A 504 Gateway Timeout almost always points to a slow backend server, database, or external connection. By checking logs, testing plugins, and optimizing the database, you can resolve most cases yourself. If the problem keeps recurring, a more stable hosting environment is often the most durable solution.