In our job as system administrators and DevOps engineers, we help our customers with different types of errors on their websites. In this article, we will discuss "504 gateway timeout". This error is an HTTP status code, which means that one server did not receive a timely response from another server that it accessed, trying to load a web page or execute a browser request.
Reasons of getting 504 gateway timeout
Servers that have Apache installed as a backend and Nginx as a frontend often generate this error code. The user works with the server according to the following plan: the client sends a request to the server, which is not sent directly to Apache but is sent through Nginx (this is a kind of request distributor).
If the latter was unable to receive a response from Apache, within a specified period of time, it sends the client a server error message 504 Gateway Timeout instead of the required result.
This usually happens, when the web server is down for some reason. Meanwhile, there may be the following reasons of 504 gateway timeout:
- Browser errors - occur when a browser has some errors in configurations or settings.
- DNS errors - inaccurate DNS configuration of the domain may cause errors while accessing it.
- Network issue - the bad network connection between proxy and web server may cause delayed response and as a result - "504 gateway timeout".
- Slow web server - poor performance of backend web server may cause gateway timeout.
- Firewall misconfiguration - inaccurate firewall rules may be the reason of 504 error.
If you are worried about the stability of your online business - hire DevOps engineers to fix all the errors and make your server fast as a rocket.
How to fix 504 gateway timeout error
Before digging into a problem deeper you need to determine whether the reason is on a client-side or server:
- Open the website in another browser (Chrome, Firefox, Safari, Opera, etc.)
- Refresh the website.
- Double-check the firewall and ISP.
- Open the website from another location.
- Double-check browser settings.
- Double-check your connection.
After you confirmed that the issue is on the server side - the first thing you should do is check web server logs. Our approach and checklist to fix "504 gateway timeout":
- Check DNS settings and fix them if something is configured inaccurately.
- Check the network connection and try to resolve them (even contacting hosting support may be helpful).
- Ensure firewall rules are configured properly.
- Ensure that the website is not under high traffic or hacker's attack.
- Сheck the web server performance and optimize it if needed.
- Increase 'timeout' configuration setting in proxy and web server to an adequate one.
ITsyndicate helps clients to achieve maximum security and availability of their online business. We will not only help you to solve all errors - we'll help you to prevent them! Our experts can help. Contact us today or ask your question in the comments section.