The HTTP 504 Gateway Timeout error occurs when an intermediary server, or rather a network interface, cannot respond to the browser’s request within a specified time.
This intermediary server or network interface can be a service acting as a security filter, a performance cache service, a Load Balancer, etc. This is what we call a “proxy” acting as a network gateway for your computer or for your web server traffic.
Sample schema where an Nginx Load Balancer can’t wait more and closes the connection showing a 504 Gateway Timeout error.
504 Gateway Timeout vs 499 Client Closed Request
This 504 error is similar to the 499 error that Nginx produces. The difference is that, when you get a 499, it is the client that closes the connection whereas with a 504 it is the proxy server that closes the connection.
Different 504 error messages
Different web servers may show different variations of the 504 Gateway Timeout error. Although they all mean the same thing, their naming conventions may slightly differ. The following displays a few examples of how you might see a 504 error.
504 Gateway Timeout
Nginx 504 Gateway Timeout
504 Gateway Timeout NGINX
HTTP 504
504 ERROR
Gateway Timeout (504)
HTTP Error 504 – Gateway Timeout
Gateway Timeout Error
Identify your error scenario
There are two different situations where a 504 error can occur:
Your computer is behind a proxy service. You can get 504 errors while browsing when your network traffic is passing through an intermediate proxy service. This is common in big companies and in some Internet providers in order to add a layer of security and/or to reduce the network traffic.
Your application or website is behind a proxy service. You get the error 504 only while browsing a determined website. In this case, the site throwing the error does have a proxy server acting as a Firewall, Load Balancer, or CDN (Content Delivery Network).
504 Gateway Timeout causes
We will group the error causes depending on previous proxy usage cases.
504 error causes when your computer is behind a proxy
Incorrect computer proxy settings can cause 504 errors.
Problems in the proxy service your computer is using.
Problems with your Internet service provider.
504 error causes when your website is behind a proxy
Your external Proxy service is failing.
Your website or app hangs.
Your Proxy has a low timeout.
How to fix the 504 error when your computer is behind a proxy
You can follow the next steps to find and fix the 504 Gateway timeout error when your local computer is working behind a proxy service:
Proxies provide an additional layer of security for your computer or mobile device and can also cache the websites you go to so that they load faster upon subsequent visits.
To fix the 504 Gateway Timeout Error caused by your computer, check the proxy server settings and make sure they’re correct.
This is the Mac OSX Proxy setup page you can find in the Network Configuration panel.
If your proxy setup is ok, chances are that there is a problem with the proxy service.
Check your network connectivity and proxy status
If your computer proxy settings are ok, then first of all: reboot your network modem and WiFi router. This will ensure we start with a “clean network connection setup”.
If your 504 error persists, the next step is to ask your proxy service provider.
How to fix the 504 error when your website is behind a proxy
In this case, you get the error 504 only while browsing a determined website. If this site is under your administration, follow the next solutions:
Check the Proxy service status
If you are using an external proxy service, check the status service page of this service.
This is a list of “Status Pages” of main providers of Load Balancing, CDN, and Security services:
You can have 504 errors due to a slow web server If the time spent processing and building your web page takes more time than the proxy gateway can wait.
In this previous log screenshot, you can observe that 504 errors have a “request_time” greater than 300 seconds. This is a clear case of pages with an excessive processing time. If this is your case, try one or more of these fixes:
In this sample case, 300 seconds is a reasonable waiting time. But, if waiting longer in the proxy makes sense for your affected requests: increase the timeout in your proxy.
If waiting longer does not solve the problem or it’s not an option: Increase the processing capacity of your server. By increasing the “processing power”, you will reduce the waiting time of your proxy service.
Something you should never dismiss is to try to find out if there is a code or database problem:
Look for errors in log files.
Repair and/or optimize tables and indexes. If you are running MariaDB or MySQL, chances are that you have a phpMyAdmin panel:
If your site is running with WordPress, try to find plugin conflicts with excessive CPU or database usage. To do this, we recommend you debug your WordPress with Query Monitor plugin.
Do not break your production site! Staging environments are the solution!
We are techies passionate about WordPress. With wetopi, a Managed WordPress Hosting, we want to minimize the friction that every professional faces when working and hosting WordPress projects.
Migrating sites to us is free and completely effortless on your part.
No hidden small text. No commitments. No credit card.
Try before you buy.
Privacy Overview
Our Site uses Cookies to identify you. Cookies can store your account identifier, ordering status, personalisation or website tracking.
Here you can manage your preferences regarding Cookies, including not to allow some types of Cookies.
Strictly Necessary Cookies
These cookies are needed for our website to function providing payment gateway security and their essentials. Therefore they are always on but they do not contain personally identifiable information (PII).
Cookie Settings: we store your preferences here to make sure which cookies you accept and which you don't.
Wetopi panel cookies and local storage: we store your user preferences: language, currency, and service token sessions.
Stripe: this is our payment provider and they may set some cookies to help them with fraud prevention and other issues. This is required for our payments to work.
3rd Party Cookies
Google Analytics: help us to deliver better content to our potential users. We have made sure no personally identifiable information (PII) is sent by anonymizing IPs.
Please enable Strictly Necessary Cookies first so that we can save your preferences!