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 pro­cess­ing of HTTP requests that have been sent. Network gateways and proxy servers regulate the for­ward­ing, 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 com­mu­ni­ca­tions stations prefixed, something which is generally done for practical reasons. However, if it so happens that one of the prefixed systems mal­func­tions, 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 no­ti­fi­ca­tion, 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

The Hypertext Transfer Protocol is one of the most important protocols when it comes to the transfer of web content. Operating on the ap­pli­ca­tion layer, it initiates com­mu­ni­ca­tion between the client – normally an internet browser – and the cor­re­spond­ing web server hosting the desired content. For this reason, HTTP com­mu­ni­cates the website’s hypertext, which the client software can in turn convert into text, images, etc. This exchange occurs via no­ti­fi­ca­tions 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 in­for­ma­tion on a suc­cess­ful pro­cess­ing (HTTP 200), or else in­for­ma­tion 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 pro­cess­ing of a request. This is why the message code also displays the des­ig­na­tion ‘Gateway Timeout’. The sender of the message is the server in the com­mu­ni­ca­tion 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 them­selves. Examples of fre­quent­ly 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 in­ter­me­di­ary 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 over­bur­dened 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 per­for­mance op­ti­miza­tion. However, this server is over­whelmed, 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 re­spon­si­ble for the ap­pear­ance 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 in­ac­ces­si­bil­i­ty 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 frus­trat­ing for every user. Even more so, if the service is being used for an issue of great im­por­tance, meaning that the frus­tra­tion around the timeout can quickly lead to full-on anger. Es­pe­cial­ly if you are working with cloud ap­pli­ca­tions and therefore have no offline al­ter­na­tive available, you become very reliant on a timely solution. The same applies if you are re­spon­si­ble for a web project, which becomes in­ac­ces­si­ble 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 in­ten­tion­al. Unlike, for example, if main­te­nance 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 re­spon­si­ble 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 ap­pli­ca­tion

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]. Al­ter­na­tive­ly, 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 con­fig­ured in­cor­rect­ly, 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 re­fresh­ing the page or restart­ing the browser, and you should check the relevant settings in your browser. For one, it could be that the con­fig­u­ra­tion 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 ex­pe­ri­enc­ing technical issues – although it is usually the case that specific messages like ‘Proxy server not re­spond­ing’ or ‘Proxy server refusing con­nec­tion’ 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 re­spon­si­ble for the 504 gateway timeout. As soon as you connect and go online, your internet provider au­to­mat­i­cal­ly assigns you a primary and secondary server – but it is also possible for you to choose your own name res­o­lu­tion. Both varieties are in no way fail proof, meaning that ex­pe­ri­enc­ing a timeout while con­nect­ing 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 ad­min­is­tra­tor re­spon­si­ble 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.

Note

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 com­mu­ni­cate any current problems that they or their website are ex­pe­ri­enc­ing. Fur­ther­more, 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 #web­site­down (e.g. #face­book­down) will often start trending quickly.

Option 6: Try again later

Re­gard­less of which server in the chain of com­mu­ni­ca­tion is effected, or re­gard­less of the reason why it cannot further process the query, there is nothing that in­di­vid­ual measures like restart­ing, etc. can do to solve a HTTP error 504. You simply have to wait until the website operator or indeed the provider re­spon­si­ble has fixed the issue. If a website displays the error message for a longer time, or even in regular intervals, then it is rec­om­mend­ed 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 guar­an­tee­ing a high level of avail­abil­i­ty. A stable hosting en­vi­ron­ment and pro­tec­tion 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 im­me­di­ate­ly set about iden­ti­fy­ing 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 re­spon­si­ble for the gateway timeout. It may also depend on whether the project has grown dra­mat­i­cal­ly in a short amount of time and visitor numbers have shot up, and at the same time, whether the proxy has necessary resources for pro­cess­ing 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 over­loaded. Here the solution is to purchase ad­di­tion­al 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 in­suf­fi­cient server power/space. This is es­pe­cial­ly 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 ad­di­tion­al power, so that all incoming HTTP requests can be processed without any danger of problems or, more im­por­tant­ly, 504 error messages.

Option 2: Adjust the proxy server settings

It is not always nec­es­sar­i­ly 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 con­fig­ured in­cor­rect­ly and therefore the pro­cess­ing of client queries is not working as it should. For example, this is a common oc­cur­rence with the con­fig­u­ra­tion-related 504 gateway timeout for NGINX proxy servers. This can usually be rectified with a couple of small, ad­di­tion­al entries in the con­fig­u­ra­tion file.

proxy_connect_timeout  600;
proxy_send_timeout    600;
proxy_read_timeout    600;
send_timeout      600;

If you use NGINX in com­bi­na­tion with FastCGI (php-fpm) then there is similarly the pos­si­bil­i­ty of a HTTP 504 error. However, this problem can be solved easily with a couple of ad­just­ments: 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:

fastcgi_read_timeout 300;

Ul­ti­mate­ly, 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 man­age­ment system and databases

The cause of the 504 gateway timeout does not always nec­es­sar­i­ly have something to do with the server software. If the HTTP pro­cess­ing time is excessive, this could also be down to your content man­age­ment system, database system, and/or other ap­pli­ca­tions not working correctly. This means that if your customers are often being con­front­ed 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 con­fig­u­ra­tion; a problem which needs to be iden­ti­fied and adjusted as necessary. Another pos­si­bil­i­ty, and one which is often the cause of CMS errors, comes from using faulty or old plug-ins – these should then be de­ac­ti­vat­ed or else updated.

Note

An effective way to protect yourself from HTTP 504 errors is to fre­quent­ly back up all your databases, create your CMS, and always install updates on time. Choosing which ex­ten­sions you should use should depend on factors like up-to-dateness, trust­wor­thi­ness, and com­pat­i­bil­i­ty. Ad­di­tion­al­ly, it is also rec­om­mend­ed that you keep the amount of plug-ins rel­a­tive­ly low, so that the content man­age­ment 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 ap­pli­ca­tions, and therefore is not your re­spon­si­bil­i­ty. In this case, it is a server within the chain of com­mu­ni­ca­tion, operated by your internet service provider or hosting server, that is at fault. Here, the only pos­si­bil­i­ty you have is to get in contact with the web host or internet provider, and to ask them to repair the problem. Fur­ther­more, 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 ex­pe­ri­enc­ing 504 error problems.

Go to Main Menu