You are currently viewing How to Fix 504 Gateway Timeout Error

How to Fix 504 Gateway Timeout Error

Have you ever faced a 504 Gateway Timeout error? If yes, You must know that it can be somewhat disruptive to your browsing experience. This error typically occurs due to communication issues between the server hosting the website and your device, possibly involving your internet service provider (ISP).

As the 504 Gateway Timeout error doesn’t tell why it occurred, it’s hard to pinpoint the cause of  the server timeout. This article will help you understand it in detail, learn how to diagnose its cause, and then fix it.

What is the 504 Gateway Timeout Error?

The 504 Gateway Timeout error is one of the most common HTTP 5XX errors encountered by website owners and site visitors. 504 Gateway Timeout Error is an HTTP status code that points out that one server did not receive a timely response from another server it was trying to communicate with while attempting to load a webpage or complete another request. This is typically a server-side issue, meaning the problem lies with the server you’re trying to access or with another server it relies on, rather than your own internet connection or browser.

How does 504 Gateway Timeout Error Appear?

The error message can vary depending on the web server and browser but commonly appears as-

Here are some common variations you may encounter:

  • 504 Gateway Timeout: Standard error code
  • HTTP 504 Error: HTTP status code
  • Server Error – 504: Indicates that the issue originates from the server
  • Gateway Timeout Error:  Directly points out a timeout at the server gateway
  • Error 504 / HTTP Error 504 / HTTP Error 504Gateway Timeout: different expressions of the error, focusing on the HTTP request failure.
  • This page isn’t workingDomain took too long to respond / 504 Gateway Time-out: a more user-friendly phrasing explaining that there’s been a delay in response.

Each of these variations indicates a common issue, that is, a delay in server response preventing the successful loading of a web page.

Why does 504 Gateway Timeout Error Occur?

Identifying the root cause is essential to resolve a 504 Gateway Timeout error. Some common triggers include:

  1. Connection Issue: Connectivity issues due to networking equipment affects communication across multiple web browsers, devices, and websites.
  2. Proxy server issues: Problems with proxy servers can break the communication between your server and the upstream server, leading to such potential timeout errors.
  3. Firewall issues: Due to faulty configuration  firewall, DDoS protection and mitigation systems or restrictions on certain ISPs or content delivery networks like Cloudflare
  4. DNS issues and unresolvable domains: When DNS servers are unable to resolve the correct IP address of domain name. It may include incorrect DNS configuration, outdated DNS caches, or recent changes in IP addresses.
  5. Web server overload: When a web server is overwhelmed with multiple requests or running low on resources, it can slow down or halt responses entirely, leading to timeouts.
  6. Limited PHP workers: Websites with a limited number of PHP workers can experience delays in processing requests, causing timeouts, especially when handling multiple simultaneous requests.

How to Fix 504 Gateway Timeout Error?

While server-side issues are typically the root cause of most 504 errors, they can also be triggered by client-side problems or false configurations. Thus, our troubleshooting guide addresses both scenarios.

While these solutions are generally applicable across various types of websites, specific steps for WordPress platforms will be listed as well.

1. Refresh the Page

First of all, refresh the web page. It is the first and simplest step in resolving a 504 Gateway Timeout error. Doing this can fix temporary connection issues, especially if the error is due to a momentary glitch or server overload. Press CTRL+R on Windows or COMMAND+R if you’re using macOS. Clear your browser’s cache and web cookies while refreshing the webpage.

However, refreshing web pages may not be effective if the server is still experiencing ongoing issues,other methods can work.

2. Try a Different Browser

Switch to a different web browser if a 504 Gateway Timeout error is specific to your primary browser. Issues such as outdated software, third-party extensions, or a corrupted browser cache can cause such an error. Alternatively, use incognito mode in your current browser.

If the web page loads successfully, the issue may lie with your primary browser’s cache, extensions, or settings.

3. Check the Proxy Server Settings

Incorrect proxy settings may disrupt communication with web servers, though that scenario is uncommon.

Here are steps to check your computer’s proxy settings:

  • For windows 11: Go to Settings>Network & Internet>Proxy. Here, you’ll see options like “Automatically detect settings” and “Use a proxy server”.
  • If “Use a proxy server” is on, ensure the address and port details are correctly set for your network.or turn off this option and then try reaccessing the website.
  • For MacOs: Click on the Apple icon and select System Settings>Network>Details>Proxies. Next to disable all proxy options by toggling off each proxy-related setting.

4. Disable Firewall

A faulty firewall configuration may mistakenly prevent legitimate network requests, leading to the 504 Gateway Timeout error.

Follow these steps to turn off your firewall temporarily:

  • For Windows 11:  Go to Start > Settings > Privacy & Security > Windows Security> Firewall & Network Protection.Choose your currently active network (for example, Private, Public, or Domain network) and turn off Microsoft Defender Firewall.
  • For MacOs: Go to System Settings > Network and click on the toggle button to turn off the firewall. After turning off the firewall, try to re-access the website to determine if faulty firewall settings were contributing to the 504 error.

Flush DNS Cache

Flushing the DNS cache can be an effective way to resolve network connection issues, such as 504 Gateway Timeout errors. This process clears outdated or corrupted DNS information that might prevent your device from connecting to websites.

To fix client-side DNS issues, try flushing your DNS cache in your operating system:

  • For Windows 11:  Search for cmd in the taskbar and right-click Command Prompt > Run as administrator and now type ipconfig /flushdns and press Enter. A message will appear “successfully flushed the DNS resolver cache”.
  • For macOs:  Open Terminal from Applications and go to Utilities. Now type sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder and press Enter. Enter your administrator password if prompted.
  • Google Chrome: Google Chrome also maintains a separate DNS cache. To clear it start Chrome, then type chrome://net-internals/#dns in the URL or address bar and press Enter. Click on the Clear host cache to flush Chrome’s DNS cache.

If your site has recently moved to a different IP address or server, you should wait for upto 48 hours for the DNS propagation process to complete since ISPs need to update their records.

6. Check Your Website’s Error Log

One of the main causes of the 504 Gateway Timeout error can be code corruption from recent updates or third-party plugins. Error logs record various issues that occur on your website, including those leading to a 504 error code.

  • Open your default File Manager application and find the wp-config.php file and edit it.
  • Add the following lines to the file right before the /* That’s all, stop editing! Happy publishing. */ line:

define( ‘WP_DEBUG’, true );

define( ‘WP_DEBUG_LOG’, true );

define( ‘WP_DEBUG_DISPLAY’, false );

Adding codes to enable debug mode on a WordPress website. Save your changes before exiting. After changing these settings, you can access raw WordPress error log files via SFTP. They are usually located in the server’s root directory under the logs folder.

7. Check Your Website’s Plugins

Sometimes, plugins on WordPress sites can lead to a 504 Gateway Timeout error. This issue arises due to plugin-related server workload increases or compatibility issues.

  • Access your WordPress admin dashboard and go to Plugins > Installed Plugins.
  • Deactivate all installed plugins. If your site becomes accessible afterward, a plugin is likely causing the issue.
  • Reactivate each plugin one by one, checking your site after each. If the error reappears, the most recently activated plugin is likely the culprit.

If disabling WordPress plugins doesn’t resolve this issue, the problem might be with your WordPress theme. Switch to a default theme via your dashboard to see if this addresses the problem.

8. Disable the CDN(Content Delivery Network)

Sometimes CDN can be the cause of a 504 Gateway Timeout error as well. Temporarily disabling your site’s CDN can help diagnose 504 issues. After disabling CDN from cPanel check your website to see if the issue is resolved. If the website accesses, keep the CDN disabled temporarily. Contact our support team for assistance in resolving this CDN-related problem.

9. Check Your Server Resources

If you face a 504 error, check your server resources, as server overload is a common cause. 

Pay attention to CPU and RAM Usage. High values indicate an overloaded server struggling with heavy traffic. Server timeouts may happen if PHP scripts exceed the server’s set execution time. Extending the maximum execution time limit can prevent such timeouts.

You can increase the maximum execution time by editing your WordPress site .htaccess file. Here’s an example snippet to add to the file:

php_value max_execution_time 60 (Adjust the number as needed for your WordPress site)

10. Contact Our Customer Support

If you’ve tried all the methods and still you are facing a 504 Gateway Timeout error, it is best to reach out to Supportfly customer support for help. SupportFly is a premier server management company. Our server support services make your servers fast and efficient.  Our primary services include Managed AWS Professional Services, cPanel Server Management, Plesk Server Management, Server consulting and much more. Supportfly provides 24×7 customer support and a comprehensive knowledge base for further information and possible solutions. 

When contacting our support, be as detailed as possible about your issue. Include your website URL, the gateway message you’ve encountered, and a summary of the steps you’ve already taken to try to resolve the issue.

Conclusion

Your website and SEO of the website can be affected by the 504 Gateway Timeout error because of multiple reasons. In this tutorial, you have learned how to fix them all. Typically, this error is caused due to server-side issues, in which case you can reach out to your host and get it resolved quickly. Resolving a 504 Gateway Timeout error requires a set of diagnostic and corrective steps. From simple activities like checking browser issues to more technical ways involving server resources and configurations, we’ve covered various 504 error solutions.