Nginx reverse proxy causing 504 gateway timeout

      29

The 504 Gateway Timeout error is one of the most common errors that website owners and visitors encounter. This HTTP status code is sent back whenever a server is unable to complete a request.

Bạn đang xem: Nginx reverse proxy causing 504 gateway timeout

Like most server errors, the 504 Gateway Timeout error can negatively impact a site when left unsolved. Thus, this guide will delve into what the error means and how to fix it effectively.

We will look at different factors that might cause this error and cover the troubleshooting steps from both the server and client-side. At the end of this guide, we will explain how this error can impact your site’s SEO and include a list of similar errors that you might run into.

What Is 504 Gateway Timeout Error and Why Does It Happen?

When you visit a website, your browser generates requests and sends them to web servers holding the required content. Each time a request is handled, the server sends back an HTTP status code along with the requested resources.

Various HTTP status codes refer to different responses. HTTP status codes beginning with the digit “5” indicate server-side errors. They appear whenever it’s impossible to complete a request due to the miscommunication between several servers.

The 504 Gateway Timeout error is an HTTP status code that appears when one server does not receive a timely response from another server that acts as a gateway or proxy. In short, it means the proxy server was unable to complete the request within the given time frame.

This HTTP error can appear in different forms and display various error messages across browsers, servers, and operating systems. Here are the most common ones:

504 Gateway Timeout NGINXGateway Timeout ErrorGateway Timeout (504)HTTP Error 504Error 504504 Error504 Gateway Time-out. The server didn’t respond in timeThis page isn’t working. Domain took too long to respondHTTP Error 504 – Gateway Timeout504 Status Code504 Error Code

To effectively fix the 504 Gateway Timeout error, you need to determine the factors and fix the issue accordingly. Here are several problems that can cause the 504 Gateway Timeout:

Connection error – if the 504 Gateway Timeout error appears in multiple browsers, devices, or websites, your network equipment might have some temporary connection problems.Web server overload – a web server running low on resources can get overloaded and slowly respond to browser requests. If a server is low on memory and receives a sudden surge of traffic, this can cause server timeouts and trigger the 504 Error.Limited PHP workers – these components handle requests whenever a visitor takes action on a WordPress website, whether it’s clicking on an internal link or searching for a product. Hence, without sufficient PHP workers, your website might fail to process several requests.

16 Ways to Fix 504 Gateway Timeout Error

Usually, the cause of 504 Gateway Timeout errors comes from the server-side. However, the error can also appear due to issues or misconfigurations from the client-side.

Thus, we’ll go through the basic troubleshooting steps with both options in mind. Part of the solutions are suitable only for WordPress, but most can work for any website.

1. Refresh the Page

The first step to troubleshoot the 504 Gateway Timeout error is the easiest one. Simply wait a couple of minutes and refresh the page. In this case, the error might happen because the server is experiencing a sudden traffic spike and cannot handle more requests.

Thus, refreshing the web page usually solves the issue. Just click the reload button on the browser or use keyboard shortcuts. On Mac, simply press the CMD + R shortcut, while Windows users can press the F5 or CTRL + F5.

While waiting, you can use online tools that check if the website is down, like Site24x7 or Host Tracker. They can confirm whether the problem is related to the local network or rooted on the server-side.

2. Try a Different Browser

If your website is online, but the 504 Gateway Timeout error still persists, try changing your current browser to a different one. Clearing browser cache or using incognito mode can also help resolve the issue and verify if the cause is browser-related.

However, before removing your browser cache, be sure to export your data and import it back once you’re done. This will prevent you from losing important browser data like bookmark lists, passwords, and setting preferences.

3. Restart the Networking Equipment

If, after trying several browsers and checking if a website is down, you have found that it’s only down on your end, there is a chance that the error comes from your internet connection.

This can happen when your network devices are misconfigured, stopping them from processing HTTP requests.

Xem thêm: Windows 7 Tips : How To Change Dim The Display Windows 7 Là Gì

The solution to this issue is rebooting your network devices. Switch off all of your networking equipment, such as a modem or router, then switch them back on. Once you’re done, reconnect your device and reload the website.

To find out whether your home connection is the culprit, try connecting the computer to a separate internet connection. If you can access the web page on this alternate network, your Wi-Fi router or modem is most likely causing the problem.

4. Temporarily Disable VPN

Using a VPN to access web pages might cause the 504 Gateway Timeout error to appear.

A VPN service uses a version of a proxy server to hide private information and add an extra layer of privacy. However, sometimes the server fails to get a response from a web server, resulting in the 504 error. In this case, try to turn off your VPN connection, reload the site, and see if it solves the problem.

Alternatively, try disabling the proxy settings on your computer. Mac users can navigate to System Preferences -> Network -> Advanced -> Proxies, then switch off the proxy server.

If you use Windows, simply go to Settings -> Network & Internet -> Proxy and locate the Manual proxy setup option.

*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
Simply double-click on the option_value of each row and change the value to the default theme name.

Once you’re done, try to access your site and see if it fixes the problem.

Does Error 504 Affect SEO?

The short answer is yes.

The 504 error happens when the proxy servers don’t receive a timely response from the origin servers while trying to serve a request. Hence, preventing your site from loading and visitors from seeing your content.

If it happens regularly and for a significant amount of time, it can negatively affect your SEO. Whenever visitors fail to reach your site, they’re more likely to leave than try to reload the page. Thus, increasing your bounce rate and risking your site ranking.

Like visitors, Google bots will also leave your website when they detect the 504 Gateway Timeout error. This can prevent them from indexing your site as the bots are unable to crawl into your website. If left unattended, it can lead to Google bots deindexing your website from the search results.

For those reasons, it is crucial to immediately examine what factors are causing the 504 error and fix it accordingly. When the problem is solved, always implement the best SEO tips to ensure a solid rank in the search engines results pages.

Types of Errors Similar to 504 Gateway Timeout

There are various HTTP status codes that browsers and servers use to interact. They are classified into five different responses:

1xx – informational2xx – successful3xx – redirection4xx – client errors5xx – server errors

Thus, apart from the 504 error, there are other common status error codes that a website can stumble upon:

By understanding various errors, website owners and developers can effectively find the proper solution to fix the problem. Hence, ensuring the site availability and optimized performance.

Conclusion

The 504 Gateway Timeout error happens when the gateway server doesn’t receive a timely response from another server, making the site unavailable. The root cause of this error usually lies on the server-side.

However, multiple factors can trigger the 504 error, from unstable internet connections to corrupted databases. Thus, it is important to examine any possible causes from the client-side.

In this guide, we’ve looked over the common steps to troubleshoot and fix the 504 Gateway Timeout error. We hope this article has helped you solve the error and return your site to its stable state.

If you have any tricks, tips, or different solutions for fixing this HTTP status code, don’t hesitate to share them in the comments section below.