When Cloudflare is able to successfully connect to a web server but it doesn’t receive any HTTP response after a while, you’ll see the pesky Error 524: A Timeout Error Occurred:
Cloudflare normally creates a TCP connection to the origin server, and it waits for a timeout period of 100 seconds for the origin server to respond.
Once the connection is established, Cloudflare starts transferring data with the help of the HTTP protocol.
In a rush? Click here to get to the fixes and skip the tech mumbo-jumbo 😉
What is Cloudflare Error 524: A Timeout Error Occurred?
While an erroneous connection will throw a more detailed error code for the given problem (like error 520 or error 521), if no connection is ever established at all you’ll see Error 524: A Timeout Occurred. The 524 error usually signals some sort of server error possibly due to a misconfigured script or a web application’s processes crashing.
A timeout error can occur when servers are overpopulated and the server is struggling to keep track of all processes running at any given time.
How To Fix Cloudflare Error 524: A Timeout Occurred
- Refresh The Webpage
- Reinstall The Application
- Check Your Server Load
- Upgrade Your System
- Check Your Traffic On Port 80
- Move to a Subdomain
- Modify Your PHP Settings
- Contact Your Hosting Provider
If a user complains to you that their connection timed out it might not be your fault.
First, make sure that the problem isn’t on their end.
1. Refresh The Webpage
Try refreshing the page. If that doesn’t help, close the browser and reload it. Sometimes a simple restart is all that’s needed to solve whatever is causing the problem.
If this doesn’t help, try clearing the cache & cookies before moving on to another step.
Restarting the browser won’t do this automatically, and sometimes a corrupted cache entry or cookie is all that’s interrupting your page from loading.
2. Reinstall The Application
If you’re experiencing an error with an application or a game, try re-installing it.
You can also contact your hosting provider to make sure that the server is not compromised.
If you get everything is working again, be sure to check your server’s traffic to see if other users may be experiencing the same problem.
Once you’re confident that the user’s computer isn’t the main issue, take the following steps to troubleshoot your Cloudflare web server.
3. Check Your Server Load
The most common cause of Error 524: A Timeout Occurred is excessive server load.
You can easily check how busy your origin server using the Cloudflare CLI is by running this command:
You’ll see the different processes running on your web server.
Look for resource-intensive tasks that are demanding high CPU and bandwidth usage.
For example, if there are too many PHP applications running too many procedures simultaneously, terminate them all.
Even though this may momentarily interrupt end-user activity it will kick open your server to accept traffic again.
MySQL processes can be an offender when too many sleep connections start stacking up.
There’s an easy command in the MySQL command prompt you can use to check for this:
show full processlist;
If you take these steps and manage to clear the 524 error then you’re on the right track. But these fixes are only a temporary stopgap.
If too many processes cluttered up your server once, it can happen again. Keep troubleshooting to get to the heart of the problem.
4. Upgrade Your System
If Error 524: A Timeout Occurred is triggered on your server it’s recommended that you check to see whether the hardware of your server is holding up.
This error can occur due to the overconsumption of hardware resources like your memory and CPU.
Simple as it may sound and frustrating as it may be, error code 524 may be a tip that it’s time to upgrade your web server hardware.
With modern equipment, you shouldn’t have trouble keeping your loading times under 100 seconds to avoid the Cloudflare error.
5. Check Your Traffic On Port 80
Under normal circumstances, your website should be able to handle traffic spikes. But error 524 means you’re facing abnormal traffic.
Anything from a faulty script to a DDoS attack could be overloading your server with HTTP requests. You can check IP address requests to your site using this server command:
netstat -an | grep 80
If you detect suspicious IP addresses spamming your server, you can block them using the command:
iptables -A INPUT -s ###.##.##.### -j DROP
And don’t forget to restart Apache:
systemctl httpd restart
It’s a good idea to regularly check on your HTTP traffic to ensure you’re not being spammed and that your web server bandwidth supports your site’s traffic as it grows.
Depending on your hosting provider, you may also be able to set up automated alerts to inform you about long-running activity spikes or suspicious connections.
6. Move to a Subdomain
If you’re not experiencing a DDoS attack or another type of external service interruption, and you’ve managed to identify a culprit, you can circumvent Error 524: A Timeout Occurred by moving the processes to a subdomain.
You can configure subdomains outside of your Cloudflare DNS app.
These “grey clouded” domains can run the processes in the background and send updates to the server without keeping the HTTP connection open.
This allows your Cloudflare to handle its incoming traffic requests while your web server handles cumbersome processes separately.
Contact your hosting provider for service-specific instructions on configuring a subdomain for your site.
7. Modify Your PHP Settings
If your web server is configured to run PHP scripts, you can set the max_execution_time variable in your php.ini file to the number of seconds you want.
For long-running scripts, a common practice is to extend load times to 2 minutes.
120 seconds is a slight increase from the default 100 seconds and is often enough extra time to allow PHP scripts to execute before triggering the 524 error.
8. Contact Your Hosting Provider
If you’ve exhausted all of the steps above and you’re still stuck, it’s time to contact your host.
Error 524 can appear for reasons beyond your control if there’s a problem at your host’s data center.
Let them know the error code, the time zone where the problem occurred, and the URL that threw the error.
This helps them identify and solve the issue as soon as possible.