504 gateway timeout is one of the HTTP status codes that a server can send back when it was unable to complete a request. While it is less frequent than 500 internal server error or 502 bad gateway error, everyone has encountered it at least a couple of times while browsing the internet. Hence this guide focuses on what 504 gateway timeout error is and how to fix it in WordPress.
When you visit any website, it generates requests and sends them to web servers that hold the required elements. Each time a request is handled, the server sends back an HTTP status code with the requested resources. By default, the HTTP status code is not displayed unless something went wrong in the process.
What is 504 Gateway Timeout?
HTTP status codes beginning with the digit “5” are server-side errors. They pop up whenever it’s impossible to complete a request due to a miscommunication between several servers.
504 gateway timeout error is an HTTP status code which appears when one server does not receive a timely response from another server that acts as a gateway or proxy. In short, it means the server was unable to complete your request within the given time frame.
504 Gateway Timeout nginx
Gateway Timeout Error
HTTP Error 504
504 Gateway Time-out – The server didn’t respond in time
HTTP Error 504 – Gateway Timeout
How to Fix 504 Gateway Timeout Error
While in most situations the cause of 504 gateway timeout errors come from the server-side, they may also pop up due to issues or misconfigurations from the user-side. Thus, we’ll go through the basic troubleshooting steps with both options in mind. Part of the solutions are suitable for WordPress, but most of them can be applied to any website.
1. Refresh the Page
The first step to troubleshoot 504 gateway timeout error is the simplest one. Wait a couple of minutes and refresh the page. It might be that the server is receiving more requests than usual at the time and is unable to handle more.
While you wait, you may use online tools that check if the website is down. It’s a great way to confirm whether the problem is related to the local network.
2. Try a Different Browser
In case the website is up, but you still see the 504 gateway timeout error, try changing up your browser to a different one. Clearing browser cache or using incognito mode can also help verify if the issue browser related.
3. Flush DNS
504 gateway timeout can sometimes be a result of incorrect or outdated DNS cache, but it is not hard to clear it. The way of doing it differs depending on your operating system. Here’s a tutorial on how to flush DNS on Windows, Linux, and Mac OS.
Temporary switching the DNS server to Google Public DNS can let you rule out if the HTTP status code appears due to a DNS problem. Though we mostly recommend this option for advanced users.
4. Test with Different Devices
Try loading the website on a different computer, network connection, or a mobile phone. In case none of the above solutions fixed the 504 gateway timeout error, this step will let you confirm if it is a local issue or a server-side problem.
5. Check Error Log
The 504 gateway timeout error may also be a cause of recent website changes or updates. The quickest way to find out is by checking the error log for any hints. WordPress users can enable error message logging by adding the following lines to the wp-config.php file:
define( 'WP_DEBUG', true ); define( 'WP_DEBUG_LOG', true ); define( 'WP_DEBUG_DISPLAY', false );
Once done, all generated entries will appear in wp-contents/debug.log file.
6. Check Plugins
While troubleshooting a 504 gateway timeout error, it’s advisable to look through your website plugins and extensions. In WordPress, plugins related to caching can be the culprit. Outdated or incompatible plugins may also cause problems. Hence disabling all of them temporarily will let you know if you’re digging in the right place.
To disable all WordPress plugins, navigate to the wp-content directory and give the plugins folder a different name.
If your site works fine when all plugins are off, the next step would be to locate which one causes the HTTP error 504. Rename the plugins directory back to its original name and this time try to disable them individually.
7. Check CDNs
If you’re utilizing a CDN to serve content faster, you should check if everything is okay from that side. One of the most frequently used solutions is CloudFlare, which acts as a CDN and a DDoS mitigation service. While using it, you can encounter two version of the 504 gateway timeout error.
The following version of 504 error appears when the issue is on CloudFlare’s side. The best approach is to contact CloudFlare support or disable it entirely. However, if you turn it off, you may have to wait a couple of hours for the DNS to propagate.
8. Tweak Server Settings
If you’re using VPS hosting, there are a few extra things you can try to fix the 504 gateway timeout error. They would involve tweaking the server settings and increasing specific resource limits.
Apache users may increase the default timeout value in the httpd.conf file. For example:
# Timeout: The number of seconds before receives and sends time out. Timeout 600
Furthermore, increasing the max_execution_time limit in php.ini can also bring positive results:
Save the changes, restart apache, and re-check. The 504 gateway timeout error should be gone if the cause was insufficient request timeout value.
If your VPS utilizes Nginx, try increasing the following values in /etc/nginx/conf.d/timeout.conf:
proxy_connect_timeout 600; proxy_send_timeout 600; proxy_read_timeout 600; send_timeout 600;
It’s also advisable to increase the max_execution_time in php.ini:
Once the changes are saved, restart Nginx and try to reach the website again.
9. Contact Customer Support
In case the 504 gateway timeout error persists after following all the above solutions, it’s advisable to contact the web hosting support staff. Try to describe what steps you took to troubleshoot the issue and provide as much information as possible to speed up the process.
In this guide, we’ve look over the common steps to troubleshoot and fix a 504 gateway timeout error. If you have any tricks, tips, or extra solutions for fixing this HTTP status code, let us know if the comments below!