What is Error 522 and how to fix it?
Error 522 is an HTTP status code indicating a connection timeout between a CDN service, like Cloudflare, and your website’s origin server. This error means Cloudflare tried to connect to your server to fetch content for a visitor, but the server took too long to respond.
To fix Error 522, you’ll need to check that your server is online, verify your Cloudflare DNS settings match your server’s IP, and check your server’s firewall and KeepAlive settings.
Here’s a quick summary of the error:
| Error code | Error 522 |
| Error type | Server error |
| Error variation | Connection timed out |
| Error causes | Server overload Firewall blocking Cloudflare IPs Incorrect DNS KeepAlive disabled |
What causes the Cloudflare Error 522?

- Server overload. The origin server is overwhelmed with too many requests and can’t respond to new ones, including Cloudflare’s. This is common on shared hosting plans, especially during sudden traffic spikes.
- Server offline. The origin server is down or offline due to a crash, maintenance, or other technical issues. If the server is offline, it can’t respond to any requests.
- Firewall blocking Cloudflare requests. A firewall on your server, a security plugin, or your hosting provider’s network might be blocking Cloudflare’s IP addresses. Since Cloudflare acts as a proxy, its IPs must be whitelisted.
- Incorrect DNS settings. The A record (or AAAA record) in your Cloudflare DNS settings doesn’t point to the correct IP address of your origin server. This sends Cloudflare’s requests to the wrong place.
- Network issues. Connectivity problems between Cloudflare and your server, or issues with your hosting provider’s network, can interrupt the connection.
- KeepAlive disabled. Cloudflare uses KeepAlive headers to maintain a stable, persistent connection. If this setting is disabled on your origin server, the connection can fail, leading to a 522 error.
Please note that the problem almost always lies with your origin server, not with Cloudflare or the visitor’s connection.
How to fix Error 522 Connection timed out
To fix a “Connection timed out” error 522, first, check if your web server is online and not overloaded. Then, verify that your Cloudflare DNS settings point to the correct server IP address. Finally, review your server’s firewall settings to confirm Cloudflare’s IPs aren’t blocked and check that KeepAlive is enabled.
If you prefer a visual guide, our video tutorial walks you through fixing Error 522:
Important! Before you start, it’s a good idea to check if your website is down for everyone using a tool like Uptrends and confirm that Cloudflare’s system status is operational.
1. Check if the web server is working
A common cause of Error 522 is an origin server that’s offline or overwhelmed by too many HTTP requests. This often happens on shared hosting plans.
First, check if your origin web server is active. You can use a ping command on Linux and Windows or traceroute on Windows to check the server’s connectivity.
Next, check your site’s resource usage. If your server is hitting its CPU or RAM limits, it won’t be able to respond to new requests. Hostinger users can find this in their hPanel:
- Navigate to Websites → Websites list → Dashboard → Hosting Plan → Resource Usage.
- Review the charts for:
- CPU usage. Keep this under 80% to avoid performance issues.
- RAM usage. The amount of memory being used.
- Processes. The total number of processes running on your account.
- Input and output. The speed of data transfer.

If you’re hitting the limits, it will slow your site and cause this error. To fix this:
- Optimize your site. Remove unnecessary plugins, as some create a high load on the server.
- Revise code. Poorly optimized code can cause high CPU usage.
- Upgrade your plan. If you regularly hit your limits, you may need to upgrade your hosting plan to get more resources.

2. Review Cloudflare DNS settings
When you add your domain to Cloudflare, it imports your DNS records. The A Record (Address Record) is crucial, as it points your domain to your server’s IP address. If this is wrong, Cloudflare sends requests to the wrong place.
First, find your server’s correct IP address. For Hostinger users:
- Go to hPanel → Websites → Websites list → Dashboard → Hosting Plan → Plan details.
- Find the Website IP address and copy it.

Next, check this IP against your Cloudflare settings:
- Log in to your Cloudflare dashboard and select your website.
- Click on the DNS app.
- Look for the A record for your main domain (for example, domain.tld).
- Check the Content value. This IP address must match the Website IP address from your hosting panel.

If the IP addresses don’t match, click Edit on the A record in Cloudflare and update the Content field with the correct IP from your hosting panel. Click Save.
DNS changes can take up to 24 hours to propagate, but this often resolves the 522 error. You can also try purging the Cloudflare cache to speed things up. Additionally, we recommend setting your Cloudflare encryption mode to Full to prevent other issues.
3. Look through other web server settings
If the server is online and DNS is correct, the issue might be with specific server settings.
Enable KeepAlive
Cloudflare uses the KeepAlive header to maintain persistent connections. If this is disabled on your server, the connection can fail. You can enable the KeepAlive header by adding the following code to your .htaccess file:
<ifModule mod_headers.c> Header set Connection keep-alive </ifModule>
Allow Cloudflare IPs
Sometimes, your server’s firewall or security rules might accidentally block Cloudflare’s IP addresses, flagging them as malicious. You must whitelist them. You can find the full list of Cloudflare IPs on their official site.
Hostinger users can easily add these IPs using the IP Manager:
- Go to hPanel → Websites → Websites list → Dashboard → Advanced → IP Manager.
- Under Allow an IP Address, add Cloudflare’s IP ranges and click Add.

Alternatively, you can add allow from rules for each Cloudflare IP in your .htaccess file.
Temporarily disable Cloudflare
If nothing else works, try pausing Cloudflare temporarily to see if the error disappears. This helps confirm if the issue is related to Cloudflare or a problem with your server.
If the site works with Cloudflare paused, the issue is in the connection between the two; if it’s still down, the problem is with your origin server.
How do I know if Error 522 has been fixed?
You’ll know Error 522 has been fixed when your website loads normally in your browser without the “Connection timed out” message.
To be certain, you can clear your browser cache and test the site again. You can also use online tools like Uptrends or GTmetrix to test your website’s accessibility from different locations.
If the site loads successfully, and you’ve confirmed your server isn’t overloaded and Cloudflare’s IPs are whitelisted, the error is resolved.
Troubleshooting other Cloudflare errors
For specific Cloudflare errors like 520 (unknown error), check for server application crashes and incompatible headers; for 521 (web server is down), verify that your origin server is active and not blocking requests; and for 524 (connection timed out), investigate long-running server processes.
Error 520: Web server is returning an unknown error
A 520 error often results from a crash in the web server application or from response headers that are incompatible with Cloudflare.
To troubleshoot it, first, double-check that your Cloudflare DNS records are correct. If they are, try temporarily disabling your .htaccess file to see if a rule is causing the problem. You can also inspect your server’s response headers and cookies to check they are formatted correctly and not too large.
Error 521: Web server is down
This error means Cloudflare could not connect to your origin server at all. The most common causes are that your server is genuinely offline or that your firewall is actively blocking Cloudflare’s requests.
To fix Error 521, verify your origin server is running and responsive. Then, test the connection to the server and, most importantly, check your firewall or security settings to confirm all of Cloudflare’s IP addresses are whitelisted.
Error 524: A timeout occurred
A 524 error is similar to a 522, but with a key difference: it means the server did establish a connection with Cloudflare but took too long to send back an HTTP response.
This almost always results from a long-running process on your server, like a complex database query or a script that is taking minutes to execute. To resolve this, you must investigate your server’s resource usage and logs to identify and optimize that slow process.
Keep your hosting environment running smoothly
Maintaining a smoothly running hosting environment requires a proactive approach, and fixing Error 522 is a key part of that. By resolving this connection timeout, you’ve restored the link between your server and Cloudflare, making your site accessible to visitors again.
To prevent this and other issues from happening in the first place, it’s important to regularly check your server’s resources, keep DNS settings accurate, and confirm your firewall rules are correct.
We also recommend you to monitor website uptime and set up instant alerts. This way, you’ll be the first to know if your site is down – from a 522 error or anything else – and can fix it before it affects your audience.
All of the tutorial content on this website is subject to Hostinger's rigorous editorial standards and values.