The 504 Gateway Timeout Error is the most common errors that we get to see on the WordPress websites. And just in case if you are too facing this error and wondering How You can Fix 504 Gateway Timeout Error in WordPress?
Then you better stick with this page. As you read further in this article, we will be discussing the solution to fix the 504 Gateway Timeout Error.
Well, we get to see the 504 gateway timeout error whenever a server fails to send back the HTTP status codes. In other words, whenever you visit a website, it sends a request to the web server and holds the required elements.
However, this appears quite a less time when compared to the 500 internal server error or 502 bad gateway error. Well to give you a better understanding of all these, let’s talk about everything one by one.
What is 504 Gateway Timeout Error?
Coming to the first question, well the errors that start with 5 are the server side errors. These errors appear whenever it fails to handle a request or because of miscommunication between several servers and gets the result in 504 gateway timeout php.
In other words, whenever you try to access a website, the web browser sends a request to the web server, and web server handles the request. Then it sends back an HTTP status code, and as a result, you get to access the website.
However, in some cases, the web server fails to handle the request. Hence, as a result, you get to see the 504 gateway timeout error. However, usually, you do not get to see this error, as all these processes happen in a hidden way. But if there is an issue, then the issue only appears.
So now that you know what is 504 gateway timeout error and why it happens. Let’s just talk about the ways to fix it.
How You can Fix 504 Gateway Timeout Error in WordPress:
The504 gateway timeout nginx is basically happening because of server side issues installed nginx. However, in some cases like504 gateway timeout apache, it causes because of user side issues as well or apache server issue. So we will talk about the solutions for both of the side issues, 504 gateway timeout, php , apache and also nginx.
Refresh the Page:
The first thing that you can try is to refresh the web page. As in most of the cases, the server side issue exists for a while. Hence if you just give a refresh to the webpage, it might work normally.so you will understand that it is a bad gateway 502 error so it fixed in a few moments.
However, in some cases, you might get to see the same 504 gateway timeout error after refreshing the webpage twice or thrice. In such cases, we would advise you to wait for at least a couple of minutes and see if it is working or not.
If it still not working, the website might be handling quite a lot of requests at a single time. Even you can also use some online tools like is it up to figure out if the website is down or not.
Try a Different Browser:
Have you tried to access the website from a different web browser like Firefox, Chrome or any other browser?
Well in most of the cases because of WordPress’s cache plugin you don’t usually get to see changes on a web page. Hence there is a high chance that the website is working fine and you are still seeing the same 504 gateway timeout error.
In this case, you can try to use a different web browser and see if it is working or not. If it is working for you, then do try to clean up the browser cache for your default browser.
However just in case if you do not have any other browser installed on your computer. Then you can use your browser’s incognito mode. If you don’t know what is incognito mode then Read the Wikipedia Article. Incognito browsers are helpful to do debug and getting the details without getting traced. Incognito browser is also called as a secret browser which does not leaves any traces and make your browsing secure.
The 504 gateway timeout error sometimes appears because of incorrect or outdated DNS cache. However, if this is the case, then there are no hard steps to follow to fix it. But the steps might vary depending on what type of operating system are you using.
Anyway, let us talk about the steps that you have to follow:
If you are a windows users, then you have to use CMD to flush DNS. For this you can simply follow these steps:
- Click on the start button.
- Type CMD.
- Now type down the ipconfig /flushdns code, and you are good to go.
If you are a Linux user, then there are different steps that you have to follow. Like if you are an Ubuntu user, then you have to type down this code in the terminal:
sudo service network-manager restart
But just in case if you run any other Linux distros, then you have to run this code in the terminal:
sudo /etc/init.d/nscd restart
Just like the Linux, there are different codes for different Mac OS versions. So let’s just have a look at all of them:
- Mac OS Sierra: sudo killall -HUP mDNSResponder
- Mac OS X El Capitan: sudo killall -HUP mDNSResponder
- Mac OS X Yosemite: sudo discoveryutil udnsflushcaches
- Mac OS X Mavericks: sudo killall -HUP mDNSResponder
- Mac OS X Mountain Lion: sudo killall -HUP mDNSResponder
- Mac OS X Lion: sudo killall -HUP mDNSResponder
- Mac OS X Snow Leopard: sudo dscacheutil -flushcache
- Mac OS X Leopard and below: sudo lookupd -flushcache
- Try a different website:
There is a pretty high chance that the above mentioned steps by now have fixed the issue. But because of some local issues you still seeing the same error.
However, in order to confirm this, you can use a different computer, a different network connection. Or you can check it via your Smartphone.
Check Error Log:
The 504 gateway timeout error may also appear because of some recent website changes or updates. To find about it, you can check for the error logs for a timeout in php files and see if there is anything wrong or not.
For this you can simply edit your wp-config.php file and add these following lines of codes:
define( ‘WP_DEBUG’, true );
define( ‘WP_DEBUG_LOG’, true );
define( ‘WP_DEBUG_DISPLAY’, false );
Once done, you will get to see all the logs in your wp-contents/debug.log file. However to edit the wp-config.php file you have to log in to your websites cpanel and the check for the files from there.
The 504 gateway timeout error also happens because of some plugins. Mainly the WordPress cache plugin can be behind this issue and also sometimes the WordPress plugin creates WordPress fatal error.
However, to fix the issue, you can simply log in to your website cpanel and then go to the file manager. From here you have to navigate to the wp-content directory.
Over here you will find a directory named as the plugins. Simply rename it and you are done. Now go ahead and check if the website is working fine or not.
If it is working fine, then there is an issue with your plugins. To fix this, have to keep the plugins directory name as it was before. Then enter to the directory and rename each plugin folder name one by one.
Are you using a CDN or content delivery network? If yes then it is might be the culprit. To fix this, you can simply contact your CDN network support team and explain your issue to them. If the issue is from their side, they will fix it for you.
Tweak Server Settings:
Just in case if your website is hosted on a VPS or Virtual Private Server. Then there are a few extra settings that you can use to fix the 504 gateway timeout error. This would including tweaking the server side settings. Anyway, here are the steps:
If you are an Apache user, then you can increase the default timeout value in the httpd.conf file to fix the error. For example:
# Timeout: The number of seconds before receives and sends time out.
Moreover, you can increase the max_execution_time limit in php.ini to see some positive results.
Once you made the changes, simply save it and restart your Apache server. Then recheck if it has solved the 504 gateway timeout error or not.
However, if you are running Nginx on your VPS servers. Then you can try out increasing the values as well. To change the following values, you have to go to the /etc/nginx/conf.d/timeout.conf:
- proxy_connect_timeout 600;
- proxy_send_timeout 600;
- proxy_read_timeout 600;
- send_timeout 600;
Even it is also advisable to increase the max_execution_time in php.ini:
- max_execution_time 300
in the end, save everything and check if your server is working fine or not.
Contact Customer Support
If the above mentioned steps do not work at all. Then the last thing that you can do is contact the customer support team. Simply raise a ticket explaining what is wrong with your WordPress websites and what steps you have taken to fix it.
So that was all for your question that says, How You can Fix 504 Gateway Timeout Error in WordPress. Now go ahead and try the steps out and see if it is working for you or not. Also for any questions, feel free to leave a comment below about how you are fixing WordPress fatal error.