Have you ever encountered a 504 error on your website? Scary thing, isn’t it?
When you’re running a business, there is never a shortage of things that can go wrong. Plenty of factors contribute to this, human factors, technological factors and even environmental factors.
And when you add a website to that mix, the opportunities for disaster just don’t stop. You have potential security breaches, or undetected downtime, or even bad UI/UX design etc.
However, let’s say you did everything perfectly. You have a secure site that loads fast.
Search engines rank it on the first result page. And then you get “An error occurred (status: 504)”. Now what? You start asking questions on Google, “What is a 504 error?”, “What is a 504 Gateway Timeout?”, “What does Gateway Timeout mean?”, and “What does 504 Gateway Timeout mean?”.
What is a 504 error?
Before we get to the error itself, it’s important that you understand how they’re generated. When you launch your browser and go to a website, it sends a request to the web server it’s hosted on.
This server then processes the request and sends back what you requested along with an HTTP header. This header has one of many status codes that communicates if everything is okay, or if there’s some problem. Not every code is bad – a 200 status code means that there isn’t any problem.
As far as the 504 error goes, there are a few 500 status error codes, such as 500, 501, 503, 504, and they all have different meanings. They indicate that the request was accepted, but the server prevented the request from being fulfilled.
In this case, a 504 gateway timeout means that the server timed out while waiting for another server to respond. You can get a 504 bad gateway when you have two servers involved in the request, and the first one times out while waiting for the second one to respond.
How the 504 status code might look to you
Some individual websites have freedom to customize how the 504 error code is displayed, but the most common ways are:
- 504 Gateway Timeout
- 504 ERROR
- Gateway Timeout (504)
- HTTP 504
The error will show up inside the browser window, just like a normal web page would. You might see the headers and footers, as well as a nice message, or you might get an all-white page, and just 504 at the top. Regardless of how that specific website shows it, it’s the same message.
The details on 504 errors
As mentioned, there are different HTTP status codes that might show up on your website at any point in time. For example, 200 status codes mean that everything is alright. 300 status codes mean that there’s a URL redirect that’s taking place.
A 400 status code will let you know that there’s an error with the end user, or “the client”. In this situation, the browser, firewall, internet connection or proxy settings are at fault. 500 status codes, such as the 504 gateway error, mean that the website’s server has a problem.
When you have a 504 error code, you most likely lose your connection to the website, or you can’t connect to it to begin with. This means that the website’s server did receive a request but can’t respond to it because processing it took too long, and it timed out.
When you want to troubleshoot a 504 error on your website, pay attention to the verbiage if you want to narrow down the root of the problem. If you have “NGINX”, or some specific web host or CDN provider’s name, the issue is on the host’s side, and it’s them you should be contacting so they can fix it.
On the other hand, if the error message is generic, the problem might be with your own configuration. The most common reason is that the server doesn’t have enough memory or bandwidth to accommodate the request. In order to fix this error, you will need to scale the resources accordingly.
How to fix the 504 Gateway Timeout errors on your website?
As described above, identifying the responsible party for such an error is actually simple. This error code indicates a server-side error, so it’s either on your end, or the host’s. However, there are actually plenty of reasons why a server wouldn’t be able to deliver a request, and throw a 504 in return.
Is it just temporary?
If you discovered the error yourself, and nobody else has reported it, refresh the website. Then, clear your browser cache. If the website returns, it’s probably just a temporary hiccup with the server, but you do need to keep an eye on it, to ensure it doesn’t happen more often.
Do you have a security breach?
If the error isn’t temporary, you’ll want to be sure that you don’t have a security threat, such as a DDoS or something similar. Check your security plugins, see if they maybe caught something. If you have a security provider hired to manage this, check with them. You will want to rule this out either way, because much more than just a server malfunction is at stake here.
Could a recent migration be the cause?
Migrating your website is fairly common nowadays, and doing it successfully isn’t much of a difficult thing. However, there are some migrations, some even as simple as moving from HTTP to HTTPS, that could result in a temporary 504 error.
This happens because the DNS records haven’t fully propagated. Your site will be giving the 504 error until that happens. If this doesn’t solve itself after some time, you will need to cache the client-side DNS servers.
Can it be the database?
If you think that the MySQL database is to blame somehow, use a plugin to repair it. WP-DBManager is a good suggestion that has been proven to work.
Have you modified your database’s files?
If you have, this might be the issue. Not an issue with the entire database, but if something was improperly modified within one of those files, that might be causing the disruption in service. The specific file to look at is the .htaccess file – roll it back to the previous version, the one before your update, and see if you fix the issue.
Did you install a new theme or plugin?
If you’ve done online searches on the 504 error topic, you’ll find that plugins are blamed pretty often for this. And it does make sense – if you don’t spend enough time checking them carefully, a new plugin, or a theme, could result in a 504 error.
If you can pinpoint when the error began showing, you know where to look in terms of adding new plugins, or maybe making upgrades. If you think that that plugin you installed at that time is to blame, deactivate it, then see if the issue persists. If that doesn’t cut it, try doing this with all plugins, one at a time. The slowdown in server response time might be caused by an improperly cached or updated plugin.
The CDN might be to blame
A popular method for troubleshooting when there’s a 400 issue, client-side, is to disable the proxy. This is because a proxy might actually be preventing the server from sending files to your browser window.
However, we have a 500 error here, and the issue is with you, not the client. The only way a proxy could be causing problems is if the CDN is in one way, or another, standing in the way of the connection. If this is the situation, you will find that the error has the CDN provider’s name somewhere in the notice, and you should be contacting them for assistance.
Ending thoughts on 504 error
As you see, there isn’t a shortage of ways to try and fix this kind of errors on your website. They’re typically server-side, and you could reach out to your host to get things fixed. However, you should know that they can also be caused by plugins, or even themes, as well as by overwhelming the PHP workers queue or backlog.
If you enjoyed reading this article about 504 error, you should read these as well: