Home
/
WordPress
/
What is a 504 Gateway Timeout error, and how to fix it?

What is a 504 Gateway Timeout error, and how to fix it?

In essence, the Internet is a global network of interconnected computers in constant communication. Typically, you can browse online for any information thanks to that interdependence. However, you may encounter connectivity issues that prevent you from accessing a website on some occasions.

A 504 Gateway Timeout is a widespread error when the upstream server can not complete your request in time. It is a frustrating experience for website visitors, which can be bad for your business.

In most cases, 504 errors are due to issues with the website itself or server-side problems. This HTTP status code may negatively affect a website’s SEO and cause a loss of visitors or revenue. Therefore, website owners should promptly take care of such errors to minimize their detrimental effects.

In this post, we will get into the 504 Gateway timeout meaning, its causes, and how to fix it.

What does the 504 Gateway Timeout Error mean?

When you try to load a website in your browser, it sends a request to the web server which hosts the site. Usually, the server would return a 200 OK status code when the request is processed successfully. However, if the server takes too long to complete this request, your browser may display the HTTP error code 504.

This error indicates that the upstream server cannot carry out your request in time to serve the website’s content.

According to the Internet Engineering Task Force (IETF), the definition of the 504 Gateway Timeout error is as follows:


The 504 (Gateway Timeout) status code indicates that the server, while acting as a gateway or proxy, did not receive a timely response from an upstream server it needed to access in order to complete the request.


The error may be a temporary occurrence due to too much traffic toward the server or site.

On the other hand, there may be a resource on the website which is taking too long to load, causing the issue. Another possibility is that your computer cannot establish a proper connection to the website due to various reasons.

Common HTTP 504 error message variations

Gateway Timeout Nginx

You may stumble upon an HTTP error 504 in different wording formats, yet it all boils down to a server-to-server communication disruption. Here are the most common variations of this error you may encounter:

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

At times, you may see the error message described in one of the following manners:

  • 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

Website owners and web hosts can also customize the error 504- gateway timeout page. For example, here is what the custom 504 error page by SiteGround looks like

504 Gateway Timeout SiteGround

SEO Impact of the 504 Error

Errors from the 5xx class refer to issues with the server completing a client’s request successfully. Such problems on your website affect user experience, eventually causing damage to your brand’s reputation.

Moreover, Search Engines are keen to take notice of prolonged 504 issues on your website. If Google bots detect that your site is down with a 504 error for too long, you may lose SEO ranking.

Therefore, fixing a 504 Gateway Timeout error on your website is not only crucial but also time-sensitive.

Causes of the 504 Gateway Timeout Error

The 504 Gateway error is usually temporary, and different reasons may cause it. Most often than not, the problem is due to a client-end issue like Internet connection troubles.

However, the hitch may be due to server-to-server network connectivity issues or a server being down. For example, when a server is under maintenance, you would likely see the 504 error on a website hosted there. Once this process is completed, the site should become accessible again.

Other culprits for an HTTP 504 error may be a traffic overload on the server, bugs in the code of a website, or DNS issues.

Additionally, this error can be due to other services acting like proxy servers for a website – CDN services, API gateways, etc.

How to fix 504 Gateway Timeout error

Although this is usually a server-side error, there is a possibility that the issue is on your end. If you see this error while visiting your favorite website, there are a few quick checks you can try to determine whether that is the case.

Refresh the page

As this may be a temporary issue due to too much traffic to the website, it is always helpful to try refreshing the page. To refresh, simply use the F5 button on a Windows machine or the Cmd + R key combination on a macOS. In case it was a temporary error, you should be able to reach the website after reloading the page.

Check your proxy server settings

Many users prefer to browse the Internet via proxy servers to keep their transactions private. Some proxy services may alter your computer’s IP address to hide your original location, while others also encrypt your web requests to keep prying eyes away. Moreover, a proxy server can block access to certain pages by their IP address.

At times, incorrect proxy settings on your computer may lead to 504 timeout errors. That is why it is best to revise yours or disable the proxy server to see if this is the culprit.

To disable the proxy settings in Windows 10, click on the Start button and select the gear icon to reach the Settings page. In this menu, you need to find the Network & Internet icon and select Proxy from the left pane.

Proxy settings Windows 10

Some computers do not have Proxy server settings by default, and if yours falls into this category – you may skip this step.

See if the website is down for other people

On some occasions, the site you cannot reach is working perfectly fine for others. Therefore, you may want to check if that is valid in your case, and there are many web tools you can use for this. For example, you can try checking with the popular web tool Is It Down Right Now to see if the site is up and running.

Is IT Down Right Now

Restart your network devices

If the web tool mentioned above shows that the site is not available just for you, the problem could be on your end. At times, incorrect settings or hardware issues may be causing the HTTP 504 error. That is why you may need to reboot your network devices like your internet router and computer.

Contact the website

In case you are still unable to reach the desired website, you may consider contacting its administrators. If there is a 504 error on the website, they are likely already working on fixing the outage. Alternatively, you may check the website’s social media accounts to see if there is any information on the issue.

Flush your computer’s DNS cache

Let’s say that the website you have just contacted informed you that they changed their domain’s DNS server. However, your PC may be trying to find the site with the old DNS records stored in the Operating System’s DNS cache. Therefore, you can also try to flush your DNS cache to ensure that it is not the source of the HTTP error 504 you are seeing.

Read these detailed articles on how to flush the DNS cache in Windows, Mac OS, or Linux machines.

Contact your ISP

Another step you can take is to contact your Internet service provider (ISP) and see if there are any connectivity issues from their end. Your ISP may be experiencing some service interruptions or doing system maintenance, which may cause a 504 error.

Try again later

As we mentioned earlier, the 504 Gateway Timeout can be just a temporary occurrence. Hence, accessing the same site later may be successful if the issue was just a temporary one.

How to Fix 504 Gateway Timeout on your website

Being a site owner comes with the responsibility to take care of any problems affecting the overall experience of your visitors. As we already mentioned, failing to resolve a 504 timeout on your site in time may impact your SEO. Keep reading to see how to fix a 504 Gateway Timeout error on your website.

DNS issues

When you transfer your website to another web server, you need to change your domain’s DNS records accordingly. Then the domain goes into a propagation period until the DNS change is recognized globally. Your site may start serving an HTTP error 504 to your visitors during that time. To check whether your domain name has propagated globally, you can use a web tool like this DNS Checker.

DNS Checker

Disable Your Site’s CDN Temporarily

At times, a CDN service like Cloudflare may not be able to get a timely response from the origin web server. That would result in an HTTP error 504 on your site, and to solve it, you may need to bypass or disable the CDN. You should note that deactivating such services may involve specific DNS changes, which would need some time to take effect.

Thus, you may bypass the CDN to see whether the error comes from the hosting web server or Cloudflare’s end. You can do this by editing your computer’s hosts file and setting your domain to point to the hosting server directly.

To do that you can insert a line like the one below into your hosts file instructing your computer to load the site from the origin server.

1.2.3.4 yourdomain.com www.yourdomain.com

Note that you need to replace “1.2.3.4” with the actual server IP for your hosting server and “yourdomain.com” with your actual domain name.

After that, you should clear your browser cache and try reloading the site again. If the site loads normally, the issue is most likely coming from the CDN service.

If that is the case, you can login to your CDN control panel and temporarily disable it.

Check your server logs

If the error is not due to DNS issues with your domain or a CDN service, you may need to check your server logs. Scrubbing through your server logs can help you pinpoint the culprit for a 504 error. SiteGround clients can find the server Error log for their site in the relevant Site Tools > Statistics > Error log.

Spam, Bots, or DDoS Attacks

Your site may be experiencing a 504 Gateway Timeout due to malicious bots crawling your site at excessive rates. They can exhaust your server resources by spawning too many requests toward your site. If your site is under a DDoS attack from bad bots generating abnormal traffic, it will serve an HTTP 504 error.

Analyzing your Access logs may help you spot IP addresses making too many requests to your site. That way, you can block the offending IPs from accessing your website.

Fix HTTP error 504 on WordPress

Popular WordPress sites and online shops tend to experience 504 errors significantly often. Read further to learn the possible causes for such errors and how to address them.

HTTP Timeouts

An HTTP Timeout can happen when you are trying to import files or products into your WordPress website, which takes too long. That could be caused by a slow internet connection, which keeps the client-server connection open for too long.

To resolve this problem, you can switch to a faster connection or use the WP-Cli for the import process. The WordPress Command-line interface allows you to execute the wp import command over SSH, significantly expediting the procedure.

Deactivate your WordPress Firewall

If you are using a security firewall like Sucuri, it is possible that their proxy servers can not establish a proper connection to the origin server. Sucuri WAF has a default timeout set to 180 seconds to protect your site from different attacks. This amount of time is considered enough for a normally functioning application to respond.

However, if the application fails to respond in that time frame, the WAF will serve you a 504 Gateway Timeout. To troubleshoot this problem, you may bypass the firewall or completely disable it.

If you can load your site afterward, the IP addresses of the service could be blocked on the hosting server firewall. Thus, you should get the IPs your firewall is using and check with your hosting provider if these are blocked for any reason.

Even if the issue is not resolved by disabling your firewall, you may at least be able to see the actual error the server is responding with.

Inspect your site’s .htaccess

As an important configuration file, the .htaccess holds directives defining the site’s behavior and restrictions. However, some WordPress plugins insert lines into that file, which causes conflicts resulting in an HTTP 504 error. That is why we highly recommend you to inspect the file and make sure it is correct.

In case you are not sure whether your .htaccess is corrupted, you can rename the file to disable it and create a default one.

You can do that via FTP, SSH, or directly from your hosting’s File manager. The default WordPress .htaccess code for basic WordPress installations is shown in the code block below.

# BEGIN WordPress

RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

# END WordPress

If your website loads properly after the default .htaccess is set, an improper directive was likely causing the 504 error.

Corrupted WordPress Database

The HTTP error 504 may result from a corrupted or not well-optimized WordPress database. To solve this, you can repair and optimize your database from PHPMyAdmin or use a WordPress plugin. Note that you should always take a backup of your database before making any changes.

Check your plugins and themes

Faulty plugins or a broken WordPress theme may cause your website to serve a 504 error. To check whether that is the case, you may try disabling the active plugins on your site and see if that will solve the problem.

If you have access to your WordPress Admin Dashboard, you can disable your plugins directly from the Plugins section.

Deactivate all plugins WP Dashoard

However, if your Admin Panel is inaccessible, you can disable all plugins at once from your Site Tools > WordPress > Install & Manage. Under the Actions menu, select the Deactivate plugins option.

Disable all plugins from Site Tools

A more complicated alternative is to disable all WordPress plugins directly from the database.

If disabling the plugins did not help you narrow it down to a conflicting plugin, the issue may be related to the theme of your site. To check this, you can switch to a default WordPress theme from your Dashboard. If your admin area is inaccessible, you can also change your theme from the database using PHPMyAdmin and see if that fixes the 504 Gateway Timeout.

Go through your site’s error log

With WordPress, you can enable the debug mode to log errors, and very often, the entries inside may point you in the right direction. SiteGround servers use the php_errorlog file to store PHP errors, and you can find it in the root folder for your WordPress installation. Looking inside it may give you an idea of what is causing the 504 error on your site.

Contact your hosting provider

Provided that none of the solutions you tried so far worked for your site, you may also contact your hosting provider. There is a good chance that the Support team will help you fix the error 504 or provide you with guidance on troubleshooting it. If you are a SiteGround client, you can reach out to all support channels 24/7.

Other errors similar to 504 – gateway timeout

The 5xx class of HTTP status codes indicates a problem on the server-side, resulting in an error message on your end. As the 504 Gateway Timeout is a time-response error, others from the 5xx branch point to different server issues.

To wrap it up, the Gateway Timeout 504 error may be time-consuming to troubleshoot and challenging to solve. With this detailed guide, you will be able to rule out any local causes and investigate server-end issues that may be causing the error for you.

Share This Article