How to fix Error HTTP 504 (Gateway Timeout)
When you launch a website with your browser, the web server is usually only the last link in a chain of systems that deal with the processing of HTTP requests that have been sent. Network gateways and proxy servers regulate the forwarding, or even the answering, of a query to absolve the web server and guarantee a quick transfer of data. In other words, the server that is contacted is one that has several communications stations prefixed, something which is generally done for practical reasons. However, if it so happens that one of the prefixed systems malfunctions, this can lead to the query failing. Instead of the desired page, your browser will display an error message like ‘HTTP Error 504’ or ‘Gateway Timeout’.
Here you can find out what exactly is behind this type of server notification, and how to go about fixing a 504 Gateway Error message (as a client user or website operator).
- HTTP 504: What’s behind the hypertext transfer protocol status code
- Why do 504 Gateway Timeouts occur?
- How to fix a 504 Gateway Timeout Error
- 504 Gateway Timeout: How to fix the problem as a browser user
- 504 error: Here are the possible solutions for website operators
HTTP 504: What’s behind the hypertext transfer protocol status code
The Hypertext Transfer Protocol is one of the most important protocols when it comes to the transfer of web content. Operating on the application layer, it initiates communication between the client – normally an internet browser – and the corresponding web server hosting the desired content. For this reason, HTTP communicates the website’s hypertext, which the client software can in turn convert into text, images, etc. This exchange occurs via notifications through which the client defines a HTTP request. The server then responds to this with an answer that includes a 504 status code, which for example might include information on a successful processing (HTTP 200), or else information on its failure, in the case of a 504 error.
The HTTP 504 response lets the client know that the cause of the failure was due to a timeout during the processing of a request. This is why the message code also displays the designation ‘Gateway Timeout’. The sender of the message is the server in the communication chain that was unable to fulfil its function as a gateway, or proxy, as it didn’t receive a response from the next server (or service) within a specific time. Exactly how the error message is displayed in the browser window is something which the website operator can decide for themselves. Examples of frequently used 504 error messages are:
- HTTP 504
- HTTP Error 504: Gateway Timeout
- Gateway Timeout (504)
- Gateway Timeout Error
- 504 Gateway Timeout
- 504 Error
- Error 504 Gateway Timeout
Why do 504 Gateway Timeouts occur?
HTTP 504 messages always occur when an intermediary server, or rather a network interface, cannot respond to the browser’s query within a clearly specified time. As has already been mentioned, this results in the affected system to not receive a response from the next link in the chain. There are several reasons why this might occur:
1. The proxy server or router in the local network, upon which the user relies, are overburdened or have even crashed, and therefore are no longer working. In this case, the 504 error is rarely limited to a single web project, but will also occur when other pages are launched.
2. The launched website will revert to a proxy server for performance optimization. However, this server is overwhelmed, or has perhaps even crashed, and can therefore no longer be reached by prefixed internet nodes – leading in turn to a gateway timeout.
3. Sometimes the incorrect proxy settings, both on the client’s side as well as the server’s, can be responsible for the appearance of a HTTP 504 message.
4. The problem affects one or several of an internet provider’s or company’s servers. This means that the inaccessibility has nothing to do with the browser user’s router or proxy settings, or indeed that of the operator of the website in question.
How to fix a 504 Gateway Timeout Error
If the requested page fails to load and instead a 504 error page appears, this is very frustrating for every user. Even more so, if the service is being used for an issue of great importance, meaning that the frustration around the timeout can quickly lead to full-on anger. Especially if you are working with cloud applications and therefore have no offline alternative available, you become very reliant on a timely solution. The same applies if you are responsible for a web project, which becomes inaccessible to users as a result of gateway timeout problems. In this case, a quick reaction is important to limit the loss of traffic to the website, and in turn, damage its turnover.
504 Gateway Timeout: How to fix the problem as a browser user
If you encounter a HTTP error 504 during your daily online activity, then it is safe to assume this is not intentional. Unlike, for example, if maintenance work is taking place when a 503 status code is displayed. A gateway timeout is nearly always a result of a server problem on part of the website operator or provider. Although as was already mentioned, it is also possible that your router or one of your own proxy settings is responsible for the error message. This means that as a browser user you have various options for fixing a HTTP 504 error:
Option 1: Reload the desired web application
In most cases, a 504 error will only appear for a pretty short time. A quick and easy option for fixing a 504 gateway timeout is therefore to simply refresh the desired web page. All that is required to this is one click on ‘Reload’ button in the address bar of the browser. This can also be done by pressing [F5] or [Ctrl] + [R]. Alternatively, you can also enter the URL again.
Option 2: Restart all network devices
If it is the case that the timeout has occurred within a home network, the problem can often be solved by resetting all your network devices. It may have happened that the modem, router, etc. has been configured incorrectly, or are failing to work properly due to other reasons, and therefore the browser’s HTTP request cannot be carried out in the specified time period. A clear sign that this is the problem is if you are unable to launch other websites as well, and instead are being met with a HTTP 504 error message.
Option 3: Review your proxy server settings
If you use a proxy server for your internet activity, and you are unable to fix a 504 error by refreshing the page or restarting the browser, and you should check the relevant settings in your browser. For one, it could be that the configuration is defective. It could also be necessary for you to select a different proxy, because the server that you have been using up until this point is no longer available or is experiencing technical issues – although it is usually the case that specific messages like ‘Proxy server not responding’ or ‘Proxy server refusing connection’ are displayed. Our guide tells you how to adjust your proxy settings in your browser.
Option 4: Changing the DNS server
It may also be the case that the DNS server being used by the router could be responsible for the 504 gateway timeout. As soon as you connect and go online, your internet provider automatically assigns you a primary and secondary server – but it is also possible for you to choose your own name resolution. Both varieties are in no way fail proof, meaning that experiencing a timeout while connecting to the DNS server is something that is always possible. In such a situation, a change to a different, free, and publicly available DNS server could be the perfect solution. Our digital guide tells you which necessary steps need to be taken for changing DNS server.
Option 5: Get in contact with the website operator and/or your provider
It may be that you have no success with changes to your own hardware and software, and in this case, you should get directly in touch with the operator of the website or the administrator responsible for the site. It may be that the cause of the HTTP 504 error lies with the web project itself. This way you will find out what the problem is straight from the horse’s mouth, as well as when the website is expected to be back in action. If the error is only happening to you or a specific group of users, then it is very likely that there is a problem with your internet provider. If this is the case then you have no other choice but to get in contact with them.
If the website in question is one that is very popular, then it could be worth having a look at social media, e.g. Twitter. Companies regularly use this medium to communicate any current problems that they or their website are experiencing. Furthermore, this is also a way for you to find out quickly whether other users are effected by the same issue. In cases like this, hashtags like #websitedown (e.g. #facebookdown) will often start trending quickly.
Option 6: Try again later
Regardless of which server in the chain of communication is effected, or regardless of the reason why it cannot further process the query, there is nothing that individual measures like restarting, etc. can do to solve a HTTP error 504. You simply have to wait until the website operator or indeed the provider responsible has fixed the issue. If a website displays the error message for a longer time, or even in regular intervals, then it is recommended that you save yourself from any more hassle and simply return to the website at a later time.
504 error: Here are the possible solutions for website operators
As the operator of a web project you want to be able to give your visitors the best possible content and very good usability, as well as also guaranteeing a high level of availability. A stable hosting environment and protection from malware, spam, etc. are equally as important as being able to react quickly to technical problems, like 504 gateway timeouts. Ideally you should be able to discover an issue like this as quickly as possible and then immediately set about identifying the cause, as well as finding the right solution.
Option 1: Increase your proxy server resources
In many cases, one’s own proxy server can be the cause of a HTTP error 504. So, if it is the case that you also use a proxy for your website, in order to relieve the web server, then it could be that this is responsible for the gateway timeout. It may also depend on whether the project has grown dramatically in a short amount of time and visitor numbers have shot up, and at the same time, whether the proxy has necessary resources for processing the HTTP requests. The same applies to isolated peak times, which are due, for example, to seasonal events such as Christmas.
If it is the case that your visitor numbers have increased and 504 error messages are appearing at times when traffic is very high, then this is a pretty clear indicator that the server is overloaded. Here the solution is to purchase additional hardware resources or to book them from your internet provider. Ideally the provider in question would take care of such an increase in advance, meaning that you can avoid any timeout as a result of insufficient server power/space. This is especially easy if you opt for a flexible solution like cloud hosting from the start. This allows you to provide your proxy server with permanent or temporary additional power, so that all incoming HTTP requests can be processed without any danger of problems or, more importantly, 504 error messages.
Option 2: Adjust the proxy server settings
It is not always necessarily the case that a problem with the proxy server has to stem from a lack of resources. It is just as likely that the server is configured incorrectly and therefore the processing of client queries is not working as it should. For example, this is a common occurrence with the configuration-related 504 gateway timeout for NGINX proxy servers. This can usually be rectified with a couple of small, additional entries in the configuration file.
If you use NGINX in combination with FastCGI (php-fpm) then there is similarly the possibility of a HTTP 504 error. However, this problem can be solved easily with a couple of adjustments: increase the value for the ‘max execution time’ in the fpm/php.ini file and also enter this value in the ‘request_terminate_timeout’ valuable in the fpm/pool.d/www.conf file. Following this you should find nginx.conf in the ‘location ~ \.php$’ block, and enter the following:
Ultimately, both options bring about a restart of NGINX, with the aim of fixing the 504 gateway timeout by carrying out these changes:
service nginx reload
Option 3: Check the content management system and databases
The cause of the 504 gateway timeout does not always necessarily have something to do with the server software. If the HTTP processing time is excessive, this could also be down to your content management system, database system, and/or other applications not working correctly. This means that if your customers are often being confronted with the error message, then you should consider that there could be a fault in one of these. Just like with the proxy servers, the most common cause is usually incorrect configuration; a problem which needs to be identified and adjusted as necessary. Another possibility, and one which is often the cause of CMS errors, comes from using faulty or old plug-ins – these should then be deactivated or else updated.
An effective way to protect yourself from HTTP 504 errors is to frequently back up all your databases, create your CMS, and always install updates on time. Choosing which extensions you should use should depend on factors like up-to-dateness, trustworthiness, and compatibility. Additionally, it is also recommended that you keep the amount of plug-ins relatively low, so that the content management system does not have to deal with more resources than planned.
Option 4: Contact the web host or your internet service provider
If up until now every attempt to fix a 504 gateway timeout has failed, then it is highly likely that the problem does not lie with your applications, and therefore is not your responsibility. In this case, it is a server within the chain of communication, operated by your internet service provider or hosting server, that is at fault. Here, the only possibility you have is to get in contact with the web host or internet provider, and to ask them to repair the problem. Furthermore, you should also make sure to ask for help if your web project has been infected by malware or has a spam problem, and for this reason is experiencing 504 error problems.