Reasons for getting 504 gateway timeout
Servers Apache and Nginx 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 routed through Nginx (this is a kind of request distributor).
Suppose the client was unable to receive a response from Apache within a specified period of time. In that case, 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 for a 504 gateway timeout:
- Browser errors - occur when a browser has some errors in configurations or settings.
- DNS errors - incorrect 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 backend web server performance may cause a gateway timeout.
- Firewall misconfiguration - inaccurate firewall rules may be the reason for 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 the client or server side:
- 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 confirm that the issue is on the server side, the first thing you should do is check the 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 it (even contacting hosting support may be helpful).
- Ensure firewall rules are correctly configured.
- Ensure that the website is not under high traffic or a hacker's attack.
- Сheck the web server performance and optimize it if needed.
- Increase the
timeoutconfiguration in the proxy and web server to an adequate one.
ITsyndicate helps clients achieve maximum security and availability for their online businesses. 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.
