Plesk & SocialBee have teamed up. Save 30% now!

504 Gateway Timeout Error: Expert Tips to Fix It

If you receive a 504 Gateway Timeout error while browsing, it’s likely to be the result of a communication problem between your device and the server hosting the affected site. That may involve your internet service provider (ISP) too. But while a 504 Gateway Timeout error may disrupt your online experience, there are ways to fix it. 

In this guide, we’ll take a closer look at the 504 Gateway Timeout error, including what causes it and how to fix it. 

504 Gateway Timeout Error Explained

A 504 Gateway Timeout error occurs when a server that’s trying to load a particular page on a website doesn’t receive a prompt response from the server hosting that site. 

In more technical terms, the central server (serving as a proxy or gateway) is attempting to access an upstream server, but when the expected timely response is undelivered, the 504 HTTP status code is returned instead. This is one of several codes that appear when an issue occurs on the server’s side. 

A 504 Gateway Timeout error is a problem with the server that hosts the site, as opposed to the internet connection or network device itself. 

Types of 504 Gateway Timeout Errors

The 504 Gateway Timeout error may appear in different ways. This depends on the server setup, device operating system, and browser used. 

The most common variations include:

  • 504 Gateway Timeout — the basic form. 
  • Server Error – 504 — shows that the server has triggered the problem.
  • HTTP 504 Error — defines it as an HTTP status code.
  • 504 Gateway Timeout NGINX / NGINX 504 Gateway Timeout — this shows a gateway timeout on NGINX servers only.
  • Gateway Timeout Error — shows a server gateway timeout directly.
  • Error 504 / HTTP Error 504 / HTTP Error 504 — Gateway Timeout — various forms that emphasize the HTTP request failure. 
  • The page request was canceled because it took too long to complete — shows a timeout has occurred in page request processing. 
  • This page isn’t working — Domain took too long to respond / 504 Gateway Time-out — The server didn’t respond in time — this is a more user-friendly form of reporting a response delay. 
  • Site visitors: There was an issue serving your request, please try again in a few minutes. — this variation tells visitors to try the page again later, as there has been a delay. 
  • Site Owners: There was a gateway timeout. You should visit your error log for more information. — this variation tells site owners that they should look at their error log for an insight. 

All of these variations indicate a shared problem behind the scenes: a server response delay that has stopped a specific page from loading properly. 

Reasons for a 504 Gateway Timeout Error 

Before you can fix a 504 Gateway Timeout error, you need to identify its cause. Here are some of the most common:

Proxy Server Problems

An issue with a proxy server can affect communication between the upstream server and your server, triggering timeouts. 

Bad Connectivity

General issues with network configurations can cause temporary loss of connection, which will disrupt communication between browsers, sites, and hardware. 

DNS Problems

Timeout issues can occur when a DNS server struggles to resolve the right IP address for a domain name. This could be down to improper DNS setup, recent IP address tweaks, and outdated DNS caches. 

Firewall Flaws

A firewall can block requests inadvertently, particularly if they have DDoS protection systems in place. That can be caused by a flawed setup or restrictions against specific CDNs and ISPs. 

Loss of Server Connectivity

Wider issues with inter-server connectivity can cause the 504 Gateway Timeout error, typically arising from a problem with the network or equipment. 

Overloaded Web Servers

Too many requests or limited resources can cause web servers to become overwhelmed. That may affect the speed of their responses or stop them altogether, creating timeouts. 

Not Enough PHP Workers

Websites that lack a sufficient amount of PHP workers may face request-processing delays. That could lead to timeouts, particularly when several requests are being handled at the same time. 

Upstream Server Failure

When an upstream server goes down, that can trigger the 504 Gateway Timeout error. 

Resolving a 504 Gateway Timeout Error

The majority of 504 errors may be caused by server-side problems, but they can be the result of poor configurations or issues on the client’s side too. We’ll look at both possibilities below. 

All of the solutions explored here are suitable for different website types, but we’ve also included processes for WordPress platforms. We’ll start with client-side fixes.

Try a Simple Reload

The most straightforward method of trying to fix a 504 Gateway Timeout error is to just reload the page. That can solve temporary problems with connectivity, particularly if it’s caused by an overloaded server or small technical hiccup. 

Just push the refresh button in your preferred browser to refresh the affected page, or try a keyboard shortcut instead. On Windows computers, push CTRL+R to refresh the current page, or use COMMAND+R on macOS. For underlying problems, clear the browser’s cache and cookies before you try to refresh the page. 

Unfortunately, this solution might not work if the server is still affected by ongoing problems. 

Switch Browsers

Changing to a different browser may be enough to solve your 504 Gateway Timeout error, but only if it’s a browser-related issue. Third-party extensions, corrupted caches, or software that’s out of date can all trigger a 504 error. Alternatively, you may try using incognito mode in your browser before you switch to a different one.

Just launch a different browser on your device and make your way to the problematic page. If the page starts working properly, the issue could be due to the affected browser’s cache, settings, or extensions. 

However, if you still can’t get the page to load, that suggests a bigger problem (maybe server-side) could be to blame. Online services such as Website Planet will reveal whether a website is down for other users. 

Assess the Proxy Server Configuration

A proxy server is positioned between the internet and your computer. It helps to keep the location of your device hidden and encrypts requests, but if your proxy server settings are configured incorrectly, that can affect communication with web servers. This isn’t particularly common, but it may happen. 

If you’re using Windows 11, follow these steps to assess the proxy settings on your device. 

  • Open Settings, followed by Network & Internet, then Proxy. This section includes Use a proxy server and Automatically detect settings.
  • When enabling Use a proxy server, make sure the port and address details align to your network properly. 
  • Otherwise, you may want to switch this option off and try to get back onto the website again. 

If you’re using macOS Sonoma, try these steps instead. 

  • Click on the Apple icon, then System Settings followed by Network.
  • Click on Details beside the network service indicator. 
  • Click on the Proxies tab, then turn off all of the proxy options. 

While proxy services aren’t used by many devices and networks as standard, browsers can feature their own proxy setup settings. Make sure you look at those too. However, changing your network settings can disrupt your access to the internet and trigger additional issues. Always take care when adjusting network settings. 

Wipe Your DNS Cache

Clearing a DNS cache can help you fix a 504 Gateway Timeout error, as it removes DNS data that is corrupted or out of date. You may be able to connect to the relevant website properly if the cache is causing the 504 error. 

For Windows 11, follow these steps to solve client-side problems with a DNS cache:

  • Type “cmd” into your taskbar then right-click Command Prompt, then Run as administrator.
  • Enter ipconfig /flushdns, then press Enter to proceed. 
  • A confirmation message will inform you that you have cleared the DNS resolver cache properly. 

For macOS Sonoma, try this:

  • Open Applications followed by Utilities, then launch Terminal.
  • Enter this: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  • Push Enter.
  • If requested to do so, type in your admin password. 

Google Chrome has its own DNS cache. You can clear it in a few simple steps:

  • Launch Chrome, then enter the following into the address bar: chrome://net-internals/#dns 
  • Push Enter.
  • Click on Clear host cache to clear out the DNS cache. 

You may have to wait a day or two for DNS propagation to finish if your site has migrated to a new server or IP address recently. That will give your ISP time to amend their records as necessary. However, you can take advantage of whatsmydns.net or similar tools to see when propagation is finished. 

If you keep experiencing problems with your DNS, try changing to Google Public DNS or another public option. That may help. 

Turn Off the Firewall

Countless people rely on firewalls to stay safe online, as they can prevent cyberattacks and keep hackers at bay. But firewall configurations can cause problems when they’re incorrect, such as blocking network requests when they don’t need to. That might cause the 504 error. 

If you use Windows 11, here’s how to temporarily disable your firewall.

  • Open the Start menu and click on Settings.
  • Click on Privacy & Security, then Windows Security. Here, open Firewall & Network Protection. 
  • Pick the network that’s active at the moment (e.g. Domain or Public). Then, disable the Microsoft Defender Firewall.

If you’re on macOS Sonoma, follow these steps. 

  • Go to System Settings, then Network.
  • Navigate down the page and click on Firewall.
  • Toggle the firewall button to the “off” position. 

Now that you’ve switched off the firewall temporarily, see if you can access the website again. If so, that means the firewall configuration was to blame. But don’t keep it deactivated, as that can leave your system more susceptible to cyber threats. 

Investigate Your Plugins

There’s a chance that WordPress website plugins can trigger the 504 error, usually due to increases in workloads or problems with compatibility. If you want to assess a plugin for a 504 error, follow these steps:

  • Open your WordPress admin dashboard, then click on Plugins followed by Installed Plugins.
  • Switch off all plugins that you have installed. If you can access your website as usual after this step, a plugin was probably to blame. 
  • Turn every plugin back one at a time. Check your website after reactivating each plugin: if you see the 504 Gateway Timeout error again, the plugin you switched back on last is highly likely to be responsible. 
  • If possible, update the plugin causing the problem. When that’s not viable, try a different plugin or contact the support team for assistance. 

 Are you struggling to reach your WordPress dashboard? Try the File Manager of your host account or an FTP client instead. After that, go to the wp-content directory then change the name of the plugins folder to deactivate all of the plugins. This will enable you to check whether your WordPress site functions properly without them.

Once you have verified that the issue is with a plugin, change the original folder name back to plugins and turn off every plugin one by one. This will identify the plugin causing the 504 error. 

Ultimately, if you can’t fix the error by turning off the WordPress plugins, your WordPress theme may be the cause. Go into your WordPress dashboard and change to a default theme to find out if this is causing the issue. 

Explore the Site’s Error Records 

Plugins created by third parties or a recent update could corrupt code and cause a 504 Gateway Timeout error. But you can access the error log for your website for an insight into the root of the issue. These keep track of problems that affect your website. 

If you use WordPress and your hosting provider doesn’t include PHP error logging as standard, the debug mode can be helpful. You can enable it on your website with these simple steps:

  • Locate the wp-config.php file in your standard file manager. 
  • Type this before the /* That’s all, stop editing! Happy publishing. */ line:
  • define( ‘WP_DEBUG’, true ); 
  • define( ‘WP_DEBUG_LOG’, true );
  • define( ‘WP_DEBUG_DISPLAY’, false );

Save your changes, then exit the file. 

What does each of these variables do?

  • WP_DEBUG — activates the debug mode for WordPress.
  • WP_DEBUG_LOG — ensures every PHP error in the wp-content/debug.log file is saved.
  • WP_DEBUG_DISPLAY — determines if debug messages can appear on HTML pages. If you set it to “false”, the errors will be hidden but still logged in the file.

Once you adjust these settings, you may view WordPress error logs through SFTP. You should find these under the logs folder in the root directory of the server. Additionally, you may find viewing the server log files beneficial when troubleshooting. 

Depending on which server is used, you’ll find server logs in the following locations:

  • NGINX servers — /var/log/nginx/error.log/.
  • Apache servers — /var/log/apache2/error.log/.

Turn Off the Content Delivery Network

A content delivery network (CDN) is crucial for increasing the speed that content is delivered and mitigating DDoS, which cultivates better site performance. But there are occasions when a CDN can lead to 504 Gateway Timeout errors too. 

You may be able to pinpoint the cause of the problem by deactivating the CND for your website temporarily. If you can get onto your website successfully after switching off your CDN, leave it deactivated on a temporary basis. Look at your CDN service’s system status to find out if they have reported any problems. 

To pause or deactivate the majority of CDN services, you should be able to find the relevant functions somewhere in the provider’s interface. However, DNS adjustments may be involved in turning off CDN services, and full propagation can take time. Once the propagation ends, go back to your site to find out if the 504 error is still appearing. 

Look for Signs of Server Overloads

Server overloads may trigger 504 Gateway Timeout errors, so look into your server resources if you can’t find any other cause. Hosting service providers assign specific resources to maintain site performance of the highest standard, though errors can still happen. 

If you find that you’re using a high level of server resources, try to bring your website’s traffic load down or improve its performance. You may need to explore new hosting plans if you’re at the limit of your current one. 

One reason for server timeouts is PHP scripts exceeding the execution time set by the server, but you can avoid this by increasing the maximum time limit for executions. But don’t set that to zero, as PHP scripts will run on and on, possibly using more server resources than you realize. 

You may tweak the .htaccess file for your WordPress site to boost the maximum execution time. For example, add php_value max_execution_time 30 to set it to 30 seconds. You can use any number that suits your site, though.

Get Your NGINX and Apache Configuration Right

If your website runs on VPS hosting, you may be able to fix 504 errors and manage timeouts by changing your NGINX and Apache settings. Follow these steps to adjust your configuration:

NGINX

  • Open the NGINX setup file, typically found in /etc/nginx/nginx.conf.
  • If your website runs on NGINX + FastCGI Process Manager (PHP-FPM) or you use NGINX as a reverse proxy for Apache, you need to change these values:
  • proxy_connect_timeout 600;
  • proxy_send_timeout 600;
  • proxy_read_timeout 600;
  • send_timeout 600;
  • fastcgi_read_timeout 300;
  • Restart the server to put these adjustments into effect. Use this command: sudo service nginx reload
  • Change the PHP-FPM pool configuration file, which you can find in /etc/php/[version]/fpm/pool.d/www.conf. Switch [version] for your PHP version.
  • Take the limit higher with request_terminate_timeout = 300.
  • Go into the php.ini file and use max_execution_time = 300.
  • Restart PHP-FPM and NGINX to put these tweaks into action. Use this command to do so: sudo service php[version]-fpm reload && sudo service nginx reload

Apache

  • Use a text editor to open the Apache setup file (usually apache2.conf or httpd.conf).
  • Increase the value of the Timeout directive. Its default value is 60 seconds, but if you wanted to boost it to 400 seconds, you would type Timeout 400.
  • Save these changes before you leave the text editor. 
  • Edit the php.ini file: boost the max_execution_time directive from the standard 30 seconds to 300. Use max_execution_time = 300 to do that. 
  • Save these changes and restart Apache with this command: sudo service apache restart

Get in Touch with Your Support Team

Are you still getting that 504 error after exhausting all of these techniques? In that case, contact your hosting provider’s customer support team for assistance. 

Give the support team as much detail about the problem as you can, such as your site’s address, the specific 504 error message you see, and all of the methods you’ve tried to fix it. 

What Impact Do 504 Errors Have on Your Ranking?

Your search engine ranking may be affected by frequent 504 Gateway Timeout errors, as they can have a negative impact on your search engine optimization (SEO) performance. Search engines use HTTPS status codes to determine your site’s accessibility and general condition. 

When websites return 504 error messages often, a search engine may conclude that those sites are not dependable, and that could cause your ranking to drop. Try these ideas to reduce the effect of 504 errors on your SEO performance:

  • Talk to your users interact with your users via social media or email to update them on the status of the problem and what you’re doing to fix it. 
  • Focus on a fast fix — the sooner you solve the problem, the less harm it will do to your SEO. Monitor your website’s status and be proactive as soon as signs of an issue appear. 
  • Use SEO tools to monitor your site — take advantage of SEO monitoring tools to pinpoint problems that could hinder your SEO. 
  • Set up a downpage — use a temporary page to notify users and search engines that you’re trying to solve the problem. 
  • Backup your website often — create website backups frequently, so you can restore them easily if 504 errors last a long time. 

Conclusion

To fix a 504 Gateway Timeout error, you need to follow clear steps to identify the cause and use the right solution. That may mean changing or disabling your CDN, checking for signs of server overloads, and other methods we’ve explored. 

Whatever technique you use, it’s vital that you address 504 errors as soon as possible. That will maintain the SEO quality of your site and its overall performance. 

FAQ

Here, we’ll answer some of the most frequently asked questions about 504 errors.

How Much Time Will a 504 Gateway Timeout Take?

The length of a 504 Gateway Timeout is usually equal to the server’s standard timeout configuration. This is typically 60 seconds, but it can vary. The timeout setting defines how long a server will wait for a response before it gives up on the other server. 

What Can I Do to Stop 504 Gateway Timeout Errors?

Make sure you monitor server loads frequently and optimize your site’s resources to help reduce the risk of 504 Gateway Timeout errors. Staying up to date with your server maintenance and maximizing the efficiency of content delivery can make timeout errors less likely. 

What Other Gateway Timeout Errors Can occur?

You may encounter other timeout errors, such as the 503 Service Unavailable and 502 Bad Gateway errors. These represent different problems with servers managing requests, and each needs particular troubleshooting methods to fix them. 

No comment yet, add your voice below!

Add a Comment

Your email address will not be published. Required fields are marked *

GET LATEST NEWS AND TIPS

  • Yes, please, I agree to receiving my personal Plesk Newsletter! WebPros International GmbH and other WebPros group companies may store and process the data I provide for the purpose of delivering the newsletter according to the WebPros Privacy Policy. In order to tailor its offerings to me, Plesk may further use additional information like usage and behavior data (Profiling). I can unsubscribe from the newsletter at any time by sending an email to [email protected] or use the unsubscribe link in any of the newsletters.

  • Hidden
  • Hidden
  • Hidden
  • Hidden
  • Hidden
  • Hidden

Related Posts

Knowledge Base