How to Troubleshoot a 504 Error on Your WordPress Site
How to Troubleshoot a 504 Error on Your WordPress Site
There are so many things that can go wrong when you run a business, and with so many contributing factors, too: human, environmental, technological. Then you throw a website into the mix and, well, you don’t need me to remind you about all the opportunities for disaster.
Ahem… security breaches, undetected downtime, rampant issues with broken links, bad UX design, and so on.
Let’s say, however, that you’ve done everything perfectly. Your site is secured. Pages load at top speeds. Search engines are happy to rank your WordPress sites on the first SERP. But then a 504 error pops up. What the…?!
Where did the 504 error come from and what does it mean? What caused it? Is it something you or the client did? And, more importantly, how do you get rid of one when it shows up on your WordPress site? This article will get you the answers to each of these questions.
The 411 on 504 Errors
There are different HTTP status codes that could potentially show up on your website at any time.
- 200 status codes are the green light of codes. In other words, everything’s all good here.
- 300 status codes indicate that there is a URL redirect taking place.
- 400 status codes are reflective of errors with the end user, or what’s referred to as “the client”. If you or your visitors see a 400 error when browsing the web, then it means that something like the browser, Internet connection, firewall, or proxy settings are to blame.
- 500 status codes–including the 504 gateway timeout error–mean that something is wrong with the website’s server.
When a 504 gateway timeout error shows up, it will say something like “504 gateway timeout” or “HTTP error 504”. Basically, when you lose your connection to a site or can’t connect to it to begin with, the error message on the resulting screen will have “504” in it. What this means is that the website’s server received a request, but, for some reason, is unable to respond to it because it took too long to process and it timed out.
When troubleshooting a 504 gateway timeout error on your website, pay attention to the verbiage if you want help narrowing down the root of the problem. Usually, if it mentions “NGINX” or a specific provider’s name (like a web host or CDN provider), then the issue comes from the host’s side of things and you need to contact them to fix it.
On the other hand, if it’s a generic error message, then the problem may lie with your own configuration of the hosting plan and server. The most likely reason is that your server doesn’t have enough bandwidth or memory to accommodate the request. To fix this, you’ll need to scale your resources accordingly.
How to Fix 504 Errors on Your WordPress Site
Identifying the responsible party for a 504 error is seemingly simple. Since this is indicative of a server-side error, either you or your host will be liable for the issue. However, there are any number of reasons why a server would be unable to deliver a page as requested and in turn throw a 504 error.
Unfortunately, this makes troubleshooting the actual problem particularly stressful. That’s why you’ll see so many support requests online (including in the WPMU DEV forum) whereby the developer seems to believe the error comes from one thing (like a plugin), but then ends up being something altogether different (like the DNS).
So, let’s go through the steps of checks and fixes you can use to track down the source of the problem and get your WordPress site back up and running.
1. Is It Just Temporary?
If you are the one who discovers the 504 error and it’s not reported by anyone else, refresh the page and clear your browser cache. If your website returns right away, then it was probably just a temporary hiccup with the server. Just keep an eye on it to make sure it doesn’t keep happening.
2. Is It a Security Breach?
Next, you’ll want to rule out that the issue with the server isn’t caused by an external security threat like a DDoS. Check to see if your security plugin detected anything. If you’ve hired a security provider to manage your site’s security, then check with them. Either way, you’ll want to rule this out since there’s more at risk here than just a server malfunction.
3. Is It from a Recent Migration?
Migrating a WordPress website is a common enough thing nowadays that it’s not really a secret how to pull one off successfully. That said, some website migrations, or even a shift from HTTP to HTTPS, could result in visitors receiving a temporary 504 error.
Basically, if the DNS records haven’t fully propagated, then your site may throw the 504 error message until that happens. If that doesn’t resolve on its own, you’ll want to cache your client-side DNS servers.
4. Is It the Database?
If you’re concerned that the issue somehow lies in your MySQL database, you can use a plugin like WP-DBManager to run a repair on it.
5. Is It .htaccess?
Think about the last time you modified your database’s files. While it might not be an issue with the entire database, per se, it could be something modified improperly within one of those files that’s causing the disruption in service to your site. Specifically, look at your .htaccess file. Roll it back to the last version before your update and see if that fixes the issue.
1.6 million WordPress Superheroes read and trust our blog. Join them and get daily posts delivered to your inbox - free!
6. Is It a New Plugin or Theme?
When looking around for developer questions about 504 errors, I found that plugins were overwhelmingly the first thing to be blamed… which makes sense when you think about how much trouble they can be if you’re not careful about vetting them. That said, a new plugin or theme could indeed be responsible for a 504 error.
If you can identify when exactly the error started showing on your site, check to see if you made any upgrades or added new plugins around that time. Deactivate the plugin or theme if you suspect that’s the case and then check your site again. If that doesn’t do it, you’ll want to deactivate all plugins at once and test each one by one. A plugin that’s not properly cached or updated, could cause the slowdown in server response time.
7. Is it the CDN?
One of the methods of troubleshooting often recommended for client-side 400 issues is to disable the proxy in their browser. This is because a proxy could prevent a server from sending files to a browser window.
However, since we’re talking about a 500 error here and the issue lies on your server, the only way a proxy could be at fault is if the CDN is somehow standing in the way of that connection (which can happen). If that’s the case, the 504 error message will have the CDN provider’s name mentioned in the notice. You can then reach out to them for assistance.
8. Is It the Firewall?
Similar to a web proxy, a firewall is a layer that stands between your server and a visitor’s browser. Of course, they serve different purposes, but it’s this positioning that makes both just as likely to create problems in delivering a website to one of your visitors. Temporarily disable your firewall to test this theory.
9. Is It Your Web Host?
Working with web hosts can sometimes be tricky. While they’re responsible for providing the server architecture to store your website, they’re not really a partner that’s invested in your business or website. While they do want to ensure that your site stays up and runs well (since that’s how they hold onto recurring revenue), that type of assurance isn’t always a guarantee with cheaper shared hosting plans.
Unless your site is running on managed WordPress hosting, VPS, or dedicated servers, your 504 error could possibly stem from a neighboring website that’s hogging resources on your server. Or the issue might just be due to the host’s servers running slowly as a result of network connectivity problems at the data center. If you’re sure the problem lies with the web host, contact them for help.
10. Is It NGINX?
NGINX is software that might be used on your site’s servers to enhance performance through load balancing, caching, and reverse proxying. While it’s meant to speed up your server, it could do the opposite if it’s not configured properly to handle high traffic requests. Your host should be able to help you fix those configuration settings.
11. Is It Your Hosting Plan?
Perhaps the issue doesn’t lie in your web host’s technology. Maybe they have all the resources your site needs to serve your website to visitors without issue. However, the problem is in the hosting plan selected for the website. When bandwidth and memory aren’t sufficient, a 504 error could spring up which is why you should assess the hosting plan to see if there are any adjustments to be made there.
A cloud hosting plan might be the best solution in this case as it’ll be easier to scale and keep resources in line with demand.
12. Is It the PHP Workers?
On a related note, you might find that your site’s bandwidth and memory limits are just fine. However, the problem is that your site wasn’t allocating enough PHP workers to manage the number of HTTP requests it received.
Of course, you should rule out the other issues above in case there’s a plugin that’s draining your PHP resources or there’s something else happening with your cache that’s making it difficult for PHP workers to get the job done right. If you have narrowed it down to this final point, however, your web host is the one to talk to about increasing the number of PHP workers available.
Any error that crops on your site tends to be worrisome because it’s not always that simple to find the source of it or to fix it. The best thing you could do to fend off 504 gateway timeout errors, however, is to prepare your site for large traffic surges and have the resources available to properly handle them.