Are you trying to fix Cloudflare error 504 gateway timeout ?
This guide is for you.
Cloudflare error 504 gateway timeout indicates that the web server is waiting too long for a response from another server and "timing out".
504 gateway timeout error occurs when Cloudflare is unable to establish a connection with the origin web server.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to fix Cloudflare related errors.
In this context, we shall look into the steps to fix this Cloudflare error.
Nature of error 504 gateway timeout?
Cloudflare error 504 gateway timeout happens when Cloudflare requests a web page and gets blocked by the site’s web server or firewall or load balancer, resulting in the request timeout.
It can also occur if we change the IP address of the origin web server and did not update the same in the Cloudflare portal.
Causes of error 504 gateway timeout ?
Some of the causes for the Cloudflare 504 gateway timeout error is given below:
1. Receiving 504 from the origin web server is considered as one of the common causes of 504 gateway timeout error.
2. 504 error originating from Cloudflare end.
3. The 504 gateway timeout error at Cloudflare due to large uploads.
How to fix Cloudflare error 504 gateway timeout
We will see how our Support engineers troubleshoot and fix Cloudflare 504 gateway timeout error for the above-mentioned causes.
1. Fix for Receiving 504 from the origin web server
We will ensure the below aspects at the webserver:
i. First we will check whether the IP address is correctly set for the domain in the Cloudflare portal.
ii. Then we have to ensure that the server firewall is not blocking any connections from Cloudflare. We can whitelist the Cloudflare IP addresses if they are not among the whitelisted IPs on the server.
iii. High load on the server can also lead to timeout issues and website errors. So we will check whether there are any applications running with high CPU usage, or if any website traffic is there on the webserver.
iv. Finally we will check if the web-server (httpd, apache, nginx) and Mysql services are properly running in the server by checking their status.
2. Fix for 504 error originating from Cloudflare
At times error 504 will be arising from Cloudflare’s end. In this case, Cloudflare will be already aware of the issue and working on it.
However, we will confirm this by checking "https://www.cloudflarestatus.com/" for the Cloudflare System Status.
For avoiding delays in processing the inquiry request we can provide the following details pro-actively to the Cloudflare Support:
i. The exact time and timezone when the issue occurred
ii. URL that resulted in the HTTP 504 error as a response.
3. Fix for 504 Gateway Timeout at Cloudflare Due to Large Uploads
The reason for this is the size of the uploads to the site being too large causing server timeouts.
Cloudflare limits upload file size (per HTTP POST request) to 100 MB for both Free and Pro plans.
This issue can be either on the host’s end or Cloudflare's end. To find this out we will bypass Cloudflare with the DNS hosts file and try to upload again.