Knowledgebase

How to Fix the 504 Bad Gateway Timeout Error?

The Internet is a game of actions and responses. When you hear the word internet, you visualize a huge network of large interconnected computers communicating continuously. For an action, one computer performs another computer flashes (sends) its response. This is how the continuous communication chain continues amongst the networks and clusters of computers in global cyberspace. 

Have you ever experienced a situation when your computer requested something in this huge network but never received a response? If yes, you are not the only one to witness such a situation. In simple terms, there were flaws in the communication, because of which the communication didn’t establish well. 

Besides, such missed connectivity issues irritate the users and cost the website owner his business and credibility.

In a broader perspective, this situation is known as the 504 Bad Gateway Timeout Error. 

If you also feel this issue must be addressed, let’s dig into the topic without further ado.

What Exactly is 504 Bad Gateway Timeout Error?

Whenever a user requests to load a website from his browser, it sends a request to that relevant site server. Upon successfully processing that request, the server returns a status code “200 OK,” indicating that the process has been completed successfully. However, if the server takes longer than usual to process that request, your browser may indicate this issue by displaying HTTP Error Code 504.

504 Bad Gateway Timeout Error

This displayed error indicates that the server from which the information was requested was incapable of processing the request and returning it to the requesting server. 

There are 2 probabilities here:

The first possibility is that this error is temporary. The upstream server was too busy processing the previous requests and had no room (free resources) to process the current (newly received) request. 

The second possibility is that your computer could not establish a reliable connection with the upstream server, accepting that the upstream server was in perfect shape and performing well. This might happen due to multiple reasons.

Keeping aside the reasons, this 504 Bad Gateway Timeout Error is the most irritating barrier between your business and your visitor’s expectations and requirements. Such recurring errors might harm your website’s SEO and brand credibility.   


Also Read: A Simple Guide To Connect Your cPanel Email to Gmail


Variations of the 504 Gateway Timeout Error

There are multiple (word) formats to name this error, yet they all mean the same. Say it anyway; it ultimately means that the communication between the servers in cyberspace got disrupted. 

Here are a few shorter formats:

  • 504 Gateway Timeout
  • Gateway Timeout Error
  • 504 Gateway Timeout NGINX
  • HTTP 504
  • Gateway Timeout (504)
  • 504 Error
  • HTTP Error 504 – Gateway Timeout

Here are a few longer formats:

  • The page request got canceled because it took too long to complete
  • 504 Gateway Time-out – The server didn’t respond in time
  • This page isn’t working – Domain took too long to respond
    504 Gateway Time-out

Also Read: How to Create a PHPinfo File and View PHP Information?


What causes a 504 Gateway Timeout?

Let’s talk about the root causes of this error.

Issues with Server Connection

The majority of websites are hosted on multiple servers. If one of the servers is down for maintenance or another reason, your visitors will see a 504 Gateway Timeout Error page.

Recent changes to your DNS. 

A recent server change or a shift to a newly assigned IP address can change your website’s DNS server. The 504 Gateway Timeout Error could appear on your website’s page. It will take a few hours before these DNS changes take effect. Your website will be up and running only after that.

Improper Firewall Configuration.

As we understand, your firewall is your website’s first line of defense. This firewall is meant to safeguard it from malicious visitors or distributed denial-of-service attacks (DDoS). Improper firewall configuration can cause your firewall to misunderstand genuine requests from CDN as an attack on your server and reject them. Such an erroneous configuration will not allow smooth traffic exchange between servers leading to a 504 Gateway Timeout Error.

Bugs in your website’s code  

Your website may have a bug in its programming code. In that case, your server will not be able to answer the requests received from the CDN correctly.

Errors in Network Connectivity

If you closely observe the 504 gateway timeout error, you will see that one or more devices did not respond on time. For a website to display successfully, many network devices must communicate properly. These include modems, routers, network switches, cabling, and more. If any of these devices malfunctioned, it would generate a 504 timeout error.

Is 504 Gateway Timeout my fault?

If you are asking this question from the user’s perspective, it might not necessarily be your fault, as the server at the website’s end is non-responsive. Similarly, for a website owner, the internet connection and other peripherals at the user’s end might not be functioning well. 

Instead of naming a culprit, it is better to know the solution you can implement to resolve this error.

How Do 504 Gateway Timeout Errors Affect SEO?

Inevitably, more time will be required to fix the 504 Gateway Timeout Error on your website. However, it would be best if you still put in some work to ensure that it does not harm your site’s search engine optimization.

The 504 Gateway Timeout error prevents your website from loading, much like the other 5XX series issues. This will negatively impact both your users and search engines.

If a web crawler encounters an error code 504, it will be unable to access the website. If the website was previously indexed, its ranking could fall further down on the search engine results pages. If that keeps happening, the site may be deindexed altogether.


Also Read: How to Find & Fix All 404 Errors on Your Website?


How to Fix 504 Gateway timeout Errors as a Visitor?

As a visitor, you might face this error while visiting any website. You may help yourself by employing a few following tweaks. 

Use this marvelous tool “Is It Down Right Now?”

There are instances when you are unsure if the site is not working only for you or everyone. When in a dilemma, use this magical tool Is It Down Right Now?

It is easy and simple to use:

  1. Open the tool’s website
  2. Enter the web address of the site you wish to access and press the Check button.
  3. The tool will conduct necessary checks and returns the results.

Note: Check the following screenshot.

Open the tool’s website

This tool also shows you the Status History of that website.

your company status history

➢ Refresh your webpage

There is nothing simpler than refreshing a webpage. You press the function key F5, maybe multiple times, and your webpage will freshly load.  

As we discussed previously that this type of error is generally temporary. You might encounter this error when the internet is busy handling heavy traffic. Refresh your page, and you are good to go.

Note: Use the key combination of Cmd + R on a macOS.

➢ Fine-tune your proxy server settings

Many users utilize proxy servers to ensure the confidentiality of their Internet transactions. Various proxy services conceal your real location by masking your computer’s IP address, while others encrypt your web requests to prevent unauthorized access. Additionally, proxy servers can grant or deny access to specific URLs and web pages based on the IP addresses of their users.

There are situations where incorrect proxy settings on your PC can result in a 504 Timeout Error. Consequently, you must ensure your proxy server settings are correct or at least disabled. This will help you arrive at the root cause of the problem.

Follow these steps only if your system has proxy settings enabled by default.

From your Windows 10 PC,

  1. Click on the Start button

select start menu    2. Select the gear icon to reach the Settings page. Select the gear icon    3. From the menu, search Network & Internet or Network

Search Network & Internet or Network

    4. Go to the left panel and select Proxy.

select proxy on network option

     5. Disable your proxy.

Disable your proxy


Also Read: How to Find Out the Owner of a Website Domain


➢ Reboot your network devices

If the tool “Is It Down Right Now?” indicates that the webpage is down only for you, then the problem is at your end. Restarting or rebooting your electronic network device creates worders. You can restart your network devices to remove any temporary glitches or bottlenecks. This simple method often eliminates your issue, and you are back into action. 

You may reboot your internet router, modems, network switches, and computer. Suppose you don’t see that 504 Bad Gateway error again, then you should be able to land on your preferred website.

➢ Contact their (website) Support

If the above step doesn’t solve your issue and you still see the error message, it indicates that the error is at the website’s end and their teams are busy fixing it. Search for their social media handles for updates on this issue, or try messaging them about it. Email them your concerns, and wait for them to reciprocate.

➢ PC’s DNS Cache – Flush It

Imagine you received a reply from the website’s support team informing you that the DNS servers of the domain name have changed.

On the other hand, your computer might still be finding the old DNS records stored in the DNS cache of your operating system. Play your magic and clear your system’s DNS cache to ensure that it is not the core reason for the HTTP 504 error.

➢ Why not call up your ISP?

Your Internet Service Provider is just a call away. 

Call their support desk to check if they are facing any connectivity issues. Your ISP may be experiencing some serious service disruptions or performing emergency system maintenance. These actions might land you on a 504 gateway timed-out error message. 

Come back later

Unfortunately, if nothing works for you, the only thing that should work is “Wait and Watch.” 

In most instances, the 504 timeout error is a temporary phase and generally gets resolved with time. Return to your favorite website after a decent break, and you might successfully access it.   

How to Fix 504 Gateway Timeout Errors as a Website Owner?  

When you own a website, you must ensure that your visitors get the best experience. If your site starts developing errors, try to resolve them. The same stands for 504 error. If the error persists longer than usual, there are chances that your website’s SEO will be impacted, resulting in a loss of business.

Let’s discuss a few issues and their resolutions:

➢ DNS issues

When moving your website to a new web server, you must update your domain’s DNS records. The domain then goes through a phase of propagation until the DNS update is acknowledged globally. 

During that period, your site may begin serving HTTP error 504 to your visitors. Use a web tool like DNS Checker to see if your domain name has propagated successfully.

➢ Temporarily Disable Your Site’s CDN

Companies like Cloudflare offer reliable Content Delivery Network services or CDN. There may be times when your CDN service (offered by Cloudflare) cannot receive a response in time from the origin web server, resulting in HTTP error 504 on your site. To fix this issue, you have 2 options to act upon. Either bypass the CDN or disable it. Deactivation of these services will require DNS changes, which may take some time to take effect.

If you plan to bypass the CDN, you must edit the host file on your computer. You must point your domain directly to the hosting server if you doubt the error is coming from the hosting server. 

Adding the following line to your host file instructs your computer to load the site from the origin server.

7.6.5.4 yourcompany.com www.yourcompany.com

Note: You must replace 7.6.5.4 with the real IP address of your hosting server and your company with the real domain name.

Clear the cookies and cache of your browser and reload the website. Suppose the site loads without errors; the source of the problem is your CDN service. If this solution works for you, go to the CDN control panel and temporarily disable it. 

➢ Take a look at the server logs

If your Domain’s DNS and CDN services are not the sources for this error, then you must definitely take a look at your server logs.

Scan your server log, and you might catch hold of the reason for the 504 error.

➢ Spam, Bots, or DDoS Attacks

Your site might be witnessing a 504 Gateway Timeout because of the malicious bots crawling your site at a very high rate. In the event of a DDoS attack involving malicious bots that generate unusual traffic, it will generate an HTTP 504 error message. These malicious bots will send multiple requests to your site to exhaust all your server’s resources. This will make the server heavy and perform slowly.

By analyzing your access logs, you can identify IP addresses that generate these unusual requests for your site. You must block these identified IP addresses from accessing your site. This will help free the server resources, and they can handle genuine traffic.


Also Read: How to Check if My Server is Under DDoS Attack


How to fix 504 Gateway Timeout Errors in WordPress?

Websites build on the WordPress platform are prone to 504 errors frequently. If you have a WordPress-based online shopping website, 504 errors would be a regular site for your visitors. 

➢ HTTP Timeouts

An HTTP Timeout might occur when you attempt to import files or items into your WordPress website for a longer period. This might be caused by a sluggish internet connection, which leaves the client-server connection open for too long.

To address this issue, you can use a faster connection or an appropriate addon to speed up the import process. The WordPress Command-line interface allows you to run the wp import command through SSH, which greatly boosts the process.


Also Read: How to Redirect HTTP to HTTPS in htaccess?


➢ Disable the WordPress Firewall

Your WordPress website may be unable to establish a proper connection with the origin server if you use a security firewall. By default, the timeout is set to a low value to protect your website against different attacks. This time value is considered adequate for a normal application to respond.

Nevertheless, if the application does not respond within that time frame, the firewall will display the 504 Gateway Timeout error. You can troubleshoot this problem by disabling the firewall. If the site loads correctly, the firewall may have blocked the IP addresses of the service on the hosting server. As a result, you should obtain the IP addresses used by your firewall and contact your web hosting provider to determine if these are blocked for any reason.

However, even if you cannot resolve the issue by disabling your firewall, you may be able to identify the error the server is reporting.


Also Read: Solutions to Fix Establishing WordPress Database Connection Error


➢ Check the .htaccess of your WP site

Your .htaccess file is a crucial configuration file for your website to function properly. It contains the necessary guidelines that influence the site’s behavior and limits. A few WordPress plugins add (perhaps unnecessary) lines into that file, which causes problems resulting in an HTTP 504 error. You must thoroughly verify the file’s accuracy before proceeding.

What if you are unsure?

Suppose you are uncertain about the integrity and accuracy of your .htaccess file; you can always rename it. This will disable the file. Now you can create a fresh (new) file with the default configuration. You may use SSH, FTP, or a File Manager that your Hosting Service Provider has provided you.


Also Read: How to Find the Missing htaccess File?


➢ Accuracy of WordPress Database

A damaged or unoptimized WordPress database can be the root cause of an HTTP 504 Error. Use PHPMyAdmin or some reliable WordPress plugin to restore and optimize your site’s database. Play safe by backing up your original database before any modifications.

➢ Are your plugins and themes faulty?

A 504 error served on your website may result from a faulty plugin or a broken theme. To confirm if that’s the case, disable your active plugins (one after the other) and try loading the site. This process will help you pinpoint the source of the error.

Use your WordPress Admin Dashboard to disable your plugins from the plugin section directly.

If disabling the plugins did not resolve the problem of the conflicting plugin, your website’s corrupted or broken theme might be causing this issue. To confirm this, go to your Dashboard and switch to the default WordPress theme. If your admin section is inaccessible, you can also use PHPMyAdmin to update your theme from the database and see if it resolves the 504 Gateway Timeout.

➢ Scan your website’s error log

Enabling the Debug Mode for your WP website will help you log errors. Sometimes the secret is hidden within these entries. Scanning through them may help identify the right cause. 

A file with a name similar to php_errorlog stores the PHP errors. This file is available in the root folder of your WP installation. You can confirm the file name and its location from your Hosting provider. Scanning the log file will give you a fair idea of what is causing the 504 timeout error on your website.

Conclusion

During our journey on How to Fix the 504 Bad Gateway Timeout Error, we explored various methods to eradicate this error. There is no foolproof method that confirms resolving this issue.

As a website owner, you and your technical team must resolve this issue immediately and offer your visitors a best-in-class experience. 

If you are a user, you have limited options to try and resolve the error if it exists at your end. Nonetheless, you always have your hosting partner with you. When none of your methods work, you can share your concerns with their Support Desk, who will help you with an accurate solution to this issue.

We would love to hear from you. Host IT Smart welcomes queries for domains, web hosting, SSL certificates, and allied products. Drop a line at info@hostitsmart.com, and one of our experts will be delighted to help you.