Quick Answer
HTTP 504 Gateway Timeout means a server acting as a gateway or proxy did not receive a response from an upstream server within the required amount of time.
The error is usually server-side and can occur when an upstream server is overloaded, slow, unavailable, or experiencing network problems. Misconfigured reverse proxies, load balancers, CDNs, firewalls, DNS, or application services can also contribute to 504 errors.
If you're a visitor, retry the page after a short period and check whether the website is experiencing an outage. If you manage the website, investigate the origin server, upstream services, server logs, network connectivity, and timeout settings.
Key Takeaways
- HTTP 504 Gateway Timeout is a server-side error involving communication between a gateway or proxy and an upstream server.
- A 504 occurs when the gateway does not receive the upstream response within the required amount of time.
- Common causes include slow or overloaded upstream servers, application bottlenecks, network failures, DNS problems, and proxy or load balancer configuration issues.
- Visitors usually cannot fix the underlying cause and may need to retry later.
- Website owners should check server health, application performance, logs, upstream connectivity, DNS, reverse proxies, load balancers, and timeout configuration.
- HTTP 504 differs from HTTP 502: a 504 means the upstream response took too long, while a 502 means the gateway received an invalid upstream response.
One of the most common error codes is error code 504. It is an issue that affects both website owners and website visitors. Knowing how to fix error code 504 is critical to keeping customers from going to your competitors instead.
A big challenge with 504 gateway timeout is that it often does not tell you why it happened. Yes, a gateway has timed out, but what exactly happened, and why?
By reading this article, you will hopefully discover the answer. We will explain what error code 504 is, what causes it, how you can fix it, and how you can prevent it from happening again. It will explore causes and fixes for both website owners and website visitors. No matter where you sit on that pendulum, if you see error code 504, you will know what to do.

What Is HTTP 504 Gateway Timeout?
Error code 504 can be temporary as it could happen because there is too much traffic heading to the server or the website, but it can also take a while because there is a resource on the website that is taking too long to load.
HTTP 504 Gateway Timeout is a server error that occurs when a server acting as a gateway or proxy does not receive a timely response from another server it needs to contact to complete a request.
Modern websites often rely on multiple systems to process a request, including reverse proxies, load balancers, CDNs, API gateways, application servers, databases, and other backend services.
If one of these upstream systems takes too long to respond, the gateway may stop waiting and return HTTP 504 Gateway Timeout to the client.
For example, a reverse proxy might receive a request normally but then wait too long for the application server behind it to respond. Once the configured timeout is reached, the reverse proxy can return a 504 response.
Because the timeout generally occurs between servers, HTTP 504 is primarily a server-side error.
Variations of Error Code 504
You may have noticed we have been referring to error code 504 as 504 gateway timeout. This is because this error code can show up in a variety of ways. No matter how it shows up, it all means the same thing. If you see the number “504” on an error page, it is most likely referring to error code 504. Here are a few other ways the error code might present itself and some additional information that could help you narrow down the exact cause of the code.
- 504 Gateway Timeout – A standard 504 error message.
- 504 Gateway Timeout NGINX – Specific to NGINX servers
- NGINX 504 Gateway Timeout
- Gateway Timeout Error – Directly lets you know a timeout happened at the server gateway.
- Error 504
- HTTP Error 504 – Specifically highlights it as an HTTP status code.
- HTTP Error 504 – Gateway Timeout
- HTTP 504
- 504 Error
- Server Error – 504 – Emphasizes that the issue comes from the server.
- Gateway Timeout (504)
- This page isn’t working – Domain took too long to respond. – The server did not respond in time, letting you know there has been a delay in responding.
- 504 Gateway Time-out – The server didn’t respond in time.
- The page request was canceled because it took too long to complete.
- Or, you could just see a blank white screen.

What Causes a 504 Gateway Timeout?
A 504 Gateway Timeout occurs when an upstream service does not respond quickly enough for the gateway or proxy handling the request.
Common causes include:
- Upstream server overload: High traffic, CPU usage, memory pressure, or exhausted resources can make an upstream server respond too slowly.
- Slow application processing: Long-running database queries, API calls, background operations, or application code can delay a response.
- Upstream server outage: The application or origin server may be unavailable or unable to respond.
- Network connectivity problems: Packet loss, routing problems, or connectivity failures between servers can prevent a response from arriving in time.
- Reverse proxy or load balancer configuration: Incorrect upstream addresses, routing rules, or timeout values can result in 504 responses.
- DNS problems: Incorrect or outdated DNS records may prevent a gateway or CDN from reaching the correct origin server.
- Firewall or security rules: A firewall may block or delay communication between the gateway and upstream service.
- CDN or proxy connectivity problems: A CDN or other intermediary may be unable to receive a response from the origin within its timeout period.

How to Fix a 504 Gateway Timeout
In this section, we will be providing you with solutions that will help if you are a person visiting a website and you come across the error, or if you are a website owner and have been informed that your site is showing error code 504 gateway timeout.
Some of the most common solutions are, reloading the page, rebooting your network devices, checking proxy settings, checking for DNS issues, temporarily disabling your website’s content delivery network, checking server issues with your host, checking for spam, bots, or DDoS attacks, repairing corrupted WordPress database, checking a website’s plugins and themes, checking error logs, and configuring Apache or Nginx settings. We will explore each one of these solutions in detail.
Reloading the Webpage
The first step to solving a 504 gateway timeout error or, any proxy error code for that matter, is to refresh the page. Most of the time, this would instantly solve the issue. You can also try loading the website in a different browser to rule out the issue and move on to another solution.
Before doing so, you should also check if the website is down for anyone else. Two useful websites to check for downtown are Down For Every or Just Me and Is It Down Right Now? They will let you know if the issue is exclusive to you or if the website is down for everyone.
Reboot Your Network Devices
Since the dawn of technology, the age-old solution to most things not working is — say it with me — “Have you tried turning it off and on again?” A gateway timeout error could be due to problems with your network devices such as a modem or a router.
Rebooting them might fix the issue instantaneously. Unplug the power from the router for a few seconds and plug it back in and see if that fixes things. Just to be extra safe, check every wire’s connection to make sure they are secured correctly.
Check Proxy Settings
While it may be rare for proxy servers to cause error code 504, incorrect proxy settings can sometimes be the reason. Try disabling your proxy and reloading the webpage to see if that will fix the issue. This is a similar step if you are using a Virtual Private Network as while there is a difference between a VPN vs a proxy, they still might be causing some issues to your network.
Check for DNS
A 504 gateway timeout error can be caused by DNS issues on the server-side, the client-side, or sometimes both. The most common issue on the server-side could be the FQDN (fully qualified domain name) not resolving the correct IP address or the DNS server not responding.
This happens when you have just migrated your website to a new server or host. Keep in mind that it is important to wait for the domain’s DNS records to propagate fully. This process can take up to 24 hours.
If you are a client experiencing this issue, you can fix the DNS by flushing your local DNS cache. On Windows, you can clear it by opening the Command Prompt and entering ipconfig/flushdns. On macOS, you can open the Terminal and run sudo killall -HUP mDNSResponder.
Disable CDN Temporarily
Sometimes, the issue could be related to your content delivery network (CDN). If a website’s origin server is not reachable, most CDNs will then serve the full webpage from their cache. However, most CDNs do not enable this feature by default as it is complex to cache dynamic assets on most websites.
A simple way to troubleshoot this issue is to disable your CDN temporarily. If you are using the free CDN Enabler WordPress plugin to link your set assets to the CDN URLs, then you can deactivate the plugin and reload your website to test it. This is similar to if you are using any other plugin such as WP Rocket, Breeze, or W3 Total Cache.
Check Server Issues with your Host
Server issues are a common reason for error code 504. Since most WordPress websites are hosted on Nginx or Apache servers, they are waiting for a response from something and end up timing out. High-traffic and e-commerce websites are more prone to 504 because of server overloads as they generate many uncacheable requests. This issue can happen on any website, including simple blogs.
An overloaded server is not the only reason for a server timeout as there can be many other reasons, including:
- Slow Server Infrastructure: The server you are using to host your website may not have enough resources to handle the load. It simply hangs up trying to serve the website. The only solution to this problem is to upgrade to a server with better infrastructure.
- More PHP Threads Needed: PHP threads are used to execute your website’s code. If all the server’s PHP threads are busy, they will build up a queue. When that queue gets too big, old requests will be disregarded which may cause the server to send out error code 504. You can ask your host to increase the number of PHP threads.
- Firewall Issues: Your server’s firewall could have some errors or it could be improperly configured. A few of its rules might be preventing the server from establishing a connection properly. If you want to be certain that it is your firewall causing the issue, check your server’s error logs.
- Network Connectivity Problems: Connectivity issues between a proxy server and the web server could cause delays in responding to HTTP requests. If you are using a load balancer, there could be network connectivity issues with it.
- HTTP Timeouts: These occur when a connection between the web server and the client is kept open for too long. With WordPress sites, this can happen when running WordPress imports. You can resolve this issue with a faster internet connection.
Check for Spam, Bots, or DDoS Attacks
Malicious attackers can bring your web server to a crawl by sending too many requests. Web scraping bots can cause 504 timeouts by flooding your server with automated requests. If your website is getting spammed by bots or undergoing a DDoS attack, it can overwhelm your server and result in error code 504. You can look at your server traffic and analytics to check for any irregular patterns in the site traffic.
Check to see if a certain IP is generating more traffic than usual. If it is unfamiliar, work quickly to block that IP or temporarily ban it until you discover why they are sending that many requests at once or if their actions are meant to be harmful.
Repair Your Corrupted WordPress Database
Sometimes, error code 504 happens because of a corrupt database. This is due to corrupted database tables or files and can sometimes be caused by a serious security issue such as your website or database being hacked. Repairing the database will depend on the problem. Plugins like WP-DBManager make it easy to diagnose these issues and repair them.
Check Your Website’s Plugins and Theme
Typically, third-party plugins and themes will not cause this error. However, there might be a slight chance that they cause server timeouts by querying for many uncached requests that are generated by the plugin or theme.
The easiest way to solve this issue is to deactivate all your plugins and see if that fixes the issue. If it does, and if you are able to, reactive them one by one until the issue reappears and that will narrow down what the problem is. The issue might narrow down to an outdated plugin as well so always make sure your plugins are up to date.
Check Error Logs
Viewing your error logs can be a helpful way of troubleshooting and debugging 504 errors on your website. They can help narrow down an issue on your website quicker, especially if it is resulting from a demanding plugin. If the host you are using does not have a logging tool, you can enable WordPress debug mode by adding the following code to your wp-config.php file:
The WP_DEBUG constant will enable or disable the WP Debug mode. It has two optional companion constants that extend its features. The WP_DEBUG_LOG constant will direct all errors to be saved to a debug.log file inside the /wp-content/directory. The WP_DEBUG_DISPLAY constant will control whether drug logs show up on the HTML page. Setting this to false will hide all errors but you can review them later.
Configure Apache or Nginx Settings
You can edit your server config files to increase resource limits for specific directives. This will help in resolving the error.
For Apache Webservers:
Add the following code to your httpd.conf:
This setting will define how long the server will wait for certain requests before marking them as a network timeout issue. You may only add this directive in your httpd.conf file and not in your .htaccess file.
This is because most shared hosting providers do not allow you to modify the httpd.conf file but you can try increasing the value of the LimitRequestBody directive in your .htaccess file.
Next up, add this line to the php.ini file:
The default value is 30 seconds however, you can increase it to allow your site’s PHP scripts to run longer.
For Nginx Webservers:
If you are running your WordPress websites on Nginx and FastCGI Process Manager (PHP-FPM) or you are using Nginx as a reverse proxy for Apache, you can alter the server settings to prevent error code 504.
First, you have to edit your PHP-FPM pool config file. You can find it at the /etc/php7.4/fpm/pool.d/www.conf location in your Nginx server. You can also try running this command in your terminal to edit the PHP-FPM pool config file:
Then set the following directive:
Next, you have to edit your php.ini file which can be located at /etc/php.ini. Once you open the file, add or change the value for the max_execution_time directive to 300 seconds.
Finally, add this code to your nginx.conf file’s location block:
Then, reload Nginx and PHP-FPM for the changes to solidify.
If you are using Nginx as a reverse proxy for Apache, you can make it more forgiving towards server timeouts by adding these directives to your nginx.conf file:

HTTP 504 vs HTTP 502
HTTP 502 Bad Gateway and HTTP 504 Gateway Timeout both involve a gateway or proxy communicating with another server, but they describe different failures.
HTTP 504 Gateway Timeout means the gateway did not receive a response from the upstream server within the required amount of time.
HTTP 502 Bad Gateway means the gateway received an invalid response from the upstream server.
In simple terms:
504 = the upstream response took too long.
502 = the upstream response was invalid.
Preventing 504 Gateway Timeout
Congratulations, you now know how to fix error code 504 from the user side and the website admin side. Now, what can you do to make sure you never see 504 Gateway Timeout ever again? Here are some tips and tricks of the trade that you can follow to ensure the code never pops up, or at the very least, you see it less frequently.
- Optimize Server Performance: Upscale your server capacities to handle high traffic loads. This will prevent bottlenecks that lead to slow response times. Keep an eye on your server’s CPU usage, memory, and disk I/O to spot bottlenecks.
- Set Up Load Balancing: Implement a server system that will distribute incoming traffic to prevent overwhelming a single server.
- Implement Caching Strategies: Use efficient caching to reduce direct server requests by storing the most commonly accessed data. This will decrease processing time and enhance speeds.
- Keep Everything Updated: Make regular and frequent updates to plugins, themes, and your CMS to avoid compatibility issues. Set a day in the month to make sure everything is updated and in the latest version.
As a website owner, these steps are important to take to make sure your website is constantly operational and the risks of encountering error code 504, or any error code for that matter, are lessened. Having your website struck with a 5XX error code can result in customers heading to a competitor of yours, it can damage your SEO, and lead to lost revenue in the long run.
If you are a user seeing 504 Gateway Timeout, unfortunately, there is not much you can do to prevent seeing this error as it is a server-side issue. You can take the steps we mentioned above (trying a different browser, turning off plugins, checking your proxy settings) but ultimately, the solution will come from the website administrator.
Conclusion
Error code 504 stands for Gateway Timeout, meaning the server did not receive a timely response from an upstream server that it needed to access so it can complete a request. This can happen because of a number of reasons such as connectivity issues, firewall issues, proxy configurations, or even a server overload.
Key takeaways:
- Error code 504 is a server-side issue, meaning most likely it is a problem from the website owner and not something a user did.
- In the simplest terms, 504 Gateway Timeout means something happened between you entering the website URL and the page loading. It could be related to an issue within the website that causes the server to timeout before being able to reach it.
- For a user, steps to solving the error include refreshing the page, trying again later, trying a different browser, or checking your internet connection or proxy settings.
- For a website owner, resolving the issue should be a main priority. Steps to solve it can last anywhere from a few seconds (turning off plugins and themes) to hours on end (adjusting some code in the Nginx server).
- If you are a website owner and have had many complaints regarding error code 504, set up weekly or monthly audits to make sure everything is operating as it should and all plugins are up-to-date.
While 504 tends to be a server-side issue, rarely, the solution can come from the user’s end. You can reload the page, check your internet connection, try a different browser, or see if the issue is exclusive to you or happening to everyone else. If it is happening to everyone else, then it is up to the website admins to take charge and find the solution as quickly as possible or risk losing out on new customers, returning customers, or even their reputation.
Thankfully, resolving error code 504 from the admin side is straightforward if you follow all of the steps mentioned in this article. The next time you see that error message, take a deep breath, come back to this article, and find your solution.