Key takeaways:
- Error code 522 is an issue between Cloudflare and your origin server, indicating a server-side problem.
- Resolving error 522 requires a systematic approach, starting with verifying the server’s online status and building on from that.
- Persistent error 522s can damage your website’s SEO, reduce crawlability, and potentially lead to ranking drops.
An “Error Code 522: Connection Timed Out” message, like any other internet error, frustrates website owners and visitors. Understanding the error and its causes makes it easier to solve it and keep your website fully accessible.
This article focuses on the characteristics of error code 522, along with strategies to prevent its recurrence and ensure a consistently online and responsive site.
What does error code 522 mean?

Error code 522, often displayed as “connection timed out,” occurs when Cloudflare tries to establish a Transmission Control Protocol (TCP) connection with your website’s origin server but doesn’t receive the expected response in time. It can also happen when the server fails to acknowledge Cloudflare’s request after the connection is established.
It’s like calling someone, hearing the phone ring, but never getting an answer. Similarly, Cloudflare waits for your server to respond until the connection times out, leaving visitors with an error page instead of your website.
Fixing the error usually involves checking your origin server and network settings; it’s usually caused by a firewall blocking or limiting Cloudflare IP addresses. Server overload and incorrect Domain Name System (DNS) records can also cause the error.
To understand how DNS directs traffic to your server, read our guide on how DNS records work.
What is a “connection timed out” message?
A “connection timed out” message appears when a server doesn’t respond within the allowed time. For Cloudflare error 522, the timeout can happen while Cloudflare is trying to connect to your website’s origin server or after the connection has been established.
According to Cloudflare’s error 522 documentation, two timeout limits apply:
- 19-second connection timeout: Cloudflare doesn’t receive a SYN+ACK, which is the server’s acknowledgment of a request to establish a TCP connection, within 19 seconds.
- 90-second acknowledgment timeout: Cloudflare establishes the connection but doesn’t receive an ACK confirming its request for a website resource within 90 seconds.
If either acknowledgment doesn’t arrive in time, Cloudflare displays error 522.
How does Cloudflare trigger this error?
When someone visits your website, Cloudflare receives the request and contacts your web server (the “origin server“). To load the page, Cloudflare needs to establish a connection and receive an acknowledgment from your server.
Cloudflare uses two timeout limits during this process:
- 19-second connection timeout: If Cloudflare tries to establish a connection but your server doesn’t acknowledge it within 19 seconds, the connection times out.
- 90-second acknowledgment timeout: If the connection succeeds but your server doesn’t acknowledge Cloudflare’s request for a website resource within 90 seconds, error 522 occurs.
If either timeout is reached, Cloudflare displays a “connection timed out” error instead of the requested page. This prevents visitors from waiting indefinitely and helps the content delivery network (CDN) manage server connections efficiently.
What causes error code 522?
Several factors can cause your origin server to fail to respond to Cloudflare, resulting in error 522. Understanding what causes it is the first step toward effective troubleshooting. Here are some reasons why such an error appears:
- The origin server is offline or overloaded: The most straightforward reason is that your web server is simply down or inaccessible, or it is overwhelmed by too many requests. The problem might stem from too many people trying to access the site at once, the server not having enough capacity, inefficient programming, or an imbalance in how traffic is distributed.
- IP addresses are not whitelisted: Cloudflare uses a specific range of IP addresses. If your server’s firewall or security groups don’t whitelist these IPs – or don’t explicitly grant access only to this pre-approved list of IP addresses, while blocking all others – it will block Cloudflare’s requests.
- Incorrect DNS settings: Misconfigured DNS records, particularly your A record (which points to your server’s IP address), can prevent Cloudflare from correctly locating and connecting to your origin server.
- Keep-Alive is disabled on the origin server: If the Keep-Alive header is disabled or improperly configured on your origin server, it can cause delayed server responses, leading to 522 errors.
- Slow server or hosting plan: A server with limited resources or a slow hosting plan may miss Cloudflare’s 19-second connection timeout or 90-second acknowledgment timeout, especially under high traffic.
- Blocked ports: Your server or network may have blocked certain ports required for web traffic (e.g., 80 for HTTP or 443 for HTTPS).
What’s the difference between error 522 vs. 521, 524, and 504?
Errors 521, 522, 524, and 504 may look similar, but they occur at different points in communication between servers. Some happen when a connection fails, while others occur when a server takes too long to respond. Here’s how they compare:
| Error code | What it means |
|---|---|
| 522 | Cloudflare doesn’t receive a connection confirmation or request acknowledgment from your origin server in time. |
| 521 | Your origin server refuses Cloudflare’s connection, often because the server is offline or blocking requests. |
| 524 | Cloudflare connects to your server, but the server doesn’t send an HTTP response within the default 125-second read timeout. |
| 504 | A gateway or proxy server doesn’t receive a response in time from another server it’s trying to reach. |
For troubleshooting steps specific to other errors, check our guides on error code 521 and the 504 gateway timeout.
How to fix error code 522 (step-by-step)
Resolving 522 errors requires an orderly approach, starting with the most common causes. Here’s a step-by-step guide to help you resolve the issue.
- Check if your origin server is online
- Review your DNS and IP address settings
- Make sure Cloudflare IPs are whitelisted
- Enable Keep-Alive and check server performance
- Review firewall, server logs, or contact hosting
Step 1: Check if your origin server is online
Confirm that your origin web server is online and responsive:
- Open your browser.
- Try accessing your site directly via the origin server’s IP address (not your domain name, unless you configured your DNS to bypass Cloudflare). For example, try http://YOUR_SERVER_IP/ or https://YOUR_SERVER_IP/ in your browser. If you can access your site this way, your server is likely online.
- Note: If you don’t know your server IP, you can usually find it in your hosting control panel (cPanel, Plesk, etc.) or by checking your domain’s A record before Cloudflare was enabled.
If your server is offline, contact your hosting provider immediately. If not, proceed to the next step.
Step 2: Review your DNS and IP address settings
Ensure that Cloudflare is pointing to the correct IP address for your origin server:
- Log in to your Cloudflare account.
- In your Cloudflare dashboard, select your domain and go to DNS.
- Verify that your A record (or CNAME, if applicable) points to the public IP address of your origin server. If you’ve recently migrated hosts or changed server IPs, this is a common point of failure.
- Check if you have any custom Origin Rules configured that might be overriding your standard DNS routing to a broken IP address or port.
Correct any old or incorrect IP addresses, wait for DNS propagation, then check your site. If it still doesn’t fix your issue, proceed to the next step.
Step 3: Make sure Cloudflare IPs are whitelisted
Check if your server’s firewall or security settings are blocking Cloudflare’s IP ranges:
- Get Cloudflare’s latest IP ranges from their official website.
- Access your server’s firewall (e.g., iptables on Linux, Windows Firewall, or your hosting provider’s firewall management interface).
- If you use a web application firewall (WAF) like ModSecurity, check its logs for blocked requests from Cloudflare IPs.
- Add all Cloudflare IP ranges to your firewall’s whitelist to allow incoming connections.
After whitelisting, test your site. If a 522 still appears, proceed to the next step.
Step 4: Enable Keep-Alive and check server performance
Verify that you enabled Keep-Alive on your web server and that your server has sufficient resources.
For Keep-Alive:
- Apache: Check your httpd.conf or virtual host configuration for Keep-Alive On and a reasonable Keep-Alive timeout (e.g., 60–120 seconds).
- Nginx: Look for Keep-Alive timeout directives in your nginx.conf. Then, restart your web server software after making changes.
For server performance:
- Monitor your server’s CPU, RAM, and disk I/O usage during peak traffic times.
- Check your server’s access and error logs for issues like database errors or excessive load.
- If your site is using more resources, consider improving your website’s code, database queries, or your hosting plan.
Optimize Keep-Alive and address performance bottlenecks to resolve 522 errors. If you still come across the same issue, proceed to the last step.
Step 5: Review firewall, server logs, or contact hosting
If you haven’t solved the issue yet, inspect your server’s logs and consult your hosting provider:
- Server logs: Examine your web server access logs (e.g., Apache access_log, Nginx access.log) and error logs (error_log) around the time the 522 error occurred. Look for any unusual activity, errors, or requests from Cloudflare IPs that did not receive a response.
- Firewall logs: Check dedicated firewall logs (if available) for any blocked connections that might not be immediately apparent from general server logs.
- Hosting provider: If you still can’t identify the cause, contact your hosting provider’s support. Provide them with details about the error, the steps you’ve already taken, and the exact timestamps of the 522 errors. If Cloudflare’s network might be implicated (though rare for a 522), you might also contact Cloudflare support for further diagnosis.
Check all the areas mentioned above. This step often uncovers more complex issues or confirms a problem on the hosting provider’s end.
Seeing error code 522 as a visitor?
If you see error code 522 while visiting a website, the problem is usually with the website’s server, not your device or internet connection.
Try refreshing the page to see if the website loads. If the error persists, wait a few minutes before trying again. You can also contact the website owner to report the issue.
Since error 522 is typically a server-side problem, the website owner or hosting provider will need to resolve it.
Does error code 522 affect SEO or users?
Error code 522 can significantly impact your website’s search engine optimization (SEO) and user experience (UX). Make sure to fix it immediately to avoid the following:
- Reduced crawlability: If crawlers cannot access your site, they cannot index or reindex new or existing content.
- Ranking drops: A site that frequently returns 522 errors will likely see its rankings drop, as this indicates a poor, unreliable UX.
- De-indexing: If server errors persist, search engines can eventually drop already indexed pages from their results.
- Increased bounce rate: Visitors who encounter an error page may leave without exploring your website, resulting in lost traffic and potential customers.
- Loss of trust: Repeated errors can lead users to believe your website is unreliable or poorly maintained, encouraging them to switch to competitors.
According to Google Search Central, repeated 5xx server errors can cause Google to temporarily slow down crawling. Pages already in Google’s index may remain there initially, but prolonged server errors can eventually lead to their removal from search results.
Slow or unresponsive pages can also affect how AI agents access your content. If a page takes too long to load, an AI agent may close the connection before retrieving its content. This can limit your website’s chances of being referenced in AI-generated answers.
How can you prevent error code 522 in the future?
Preventing 522 errors involves proactive server management, proper configuration, and monitoring. Here are key strategies for reducing these errors:
- Ensure sufficient server resources: Regularly monitor your hosting server’s CPU, RAM, and disk I/O. If your traffic grows or your website becomes more resource-intensive, your current hosting plan might become inadequate.
- Upgrade your hosting plan: If resource exhaustion is a recurring issue, it’s better to invest in a more robust hosting plan (e.g., from shared to virtual private server (VPS), dedicated, or cloud hosting).
- Optimize server performance: This involves fine-tuning your server and website to handle requests more efficiently.
- Code optimization: Review your website’s code for inefficiencies. Optimize database queries, reduce unnecessary loops, and ensure efficient script execution.
- Web server configuration: Fine-tune your web server (Apache, Nginx) for optimal performance. Adjust Keep-Alive settings, worker processes, and connection limits.
- Database optimization: Regularly optimize your database tables and indexes. Consider using database caching.
- Implement robust caching: Use caching mechanisms at various levels.
- Browser caching: Instruct browsers to cache static assets (images, CSS, JS).
- Server-side caching: Use object caching (e.g., Redis, Memcached) for dynamic content.
- Cloudflare caching: Use Cloudflare’s caching capabilities to serve content directly from its edge network, reducing requests to your origin server.
- Whitelist Cloudflare IPs: To ensure uninterrupted communication, maintain an up-to-date whitelist of all Cloudflare IP addresses in your server’s firewall.
- Use uptime monitoring tools: Implement reliable uptime-monitoring tools that notify you immediately if your server goes offline or becomes unresponsive. Many services offer this, often pinging your server every few minutes.
- Check server logs regularly: Review your server’s error and access logs regularly. These logs often warn early about performance issues or configuration problems that could lead to 522 errors.
- Review Cloudflare DNS settings: Double-check your DNS settings in Cloudflare to ensure your A records correctly point to your origin server’s IP address.
- Turn on Keep-Alive: Ensure Keep-Alive is enabled and configured with appropriate timeouts on your web server to maintain persistent connections.
Frequently asked questions
It can be a temporary glitch for a few minutes if the server recovers quickly. It can also persist for hours or days if a larger issue with the origin server isn’t addressed.
Both are Cloudflare timeouts, but they happen at different stages. Error 522 occurs during the connection or request acknowledgment stage. Your origin server either doesn’t send a SYN+ACK within 19 seconds or doesn’t send an ACK within 90 seconds after connecting. Error 524 occurs after a successful connection, when your origin server takes longer than the default 125-second Proxy Read Timeout to send an HTTP response.
Cloudflare generally cannot fix error 522, as the issue lies with your origin server, not Cloudflare’s network. You’ll need to investigate and fix your server environment or contact your hosting provider.
Switching DNS providers typically does not help fix a 522 error if you already use Cloudflare for DNS and proxying. The problem is usually with your origin server’s availability or configuration after Cloudflare attempts a connection.
While Cloudflare often displays the error page, the underlying cause is almost always an issue with your website’s origin server failing to respond to Cloudflare’s requests.
You can temporarily bypass Cloudflare by editing your local hosts file to point your domain directly to your origin server’s IP address. This lets you check whether your server is accessible without Cloudflare.
First, check if your origin server is online and accessible directly via its IP address. Then, review your server’s firewall settings to ensure Cloudflare’s IP ranges are whitelisted.
No, error 522 isn’t permanent. It can last a few minutes if your server recovers on its own, or longer if the underlying issue remains unresolved. Fixing server overload, firewall restrictions, or incorrect server settings can restore the connection.
Website visitors generally cannot fix error 522 because the issue usually comes from the website’s server. You can try refreshing the page or returning after a few minutes. If the error continues, contact the website owner so they can investigate.
No, error 522 doesn’t necessarily mean your website was hacked. It usually indicates a connection problem caused by an overloaded server, firewall restrictions, or incorrect network settings. However, if you notice other suspicious activity, review your server logs and security settings for potential threats.
Keep your site moving with reliable hosting support
Error code 522 is a sign that your website’s connection path needs attention. Once you understand where Cloudflare fits between visitors and your origin server, the next move becomes clearer: check the server, confirm DNS, allow Cloudflare IPs, and review performance.
Your website should help your next customer reach you, not leave them staring at an error page. We provide web hosting to small businesses with secure, reliable hosting, expert support, and tools to keep their online presence moving forward.
When your site is ready to grow, we’re here to help you keep it connected, protected, and ready for what’s next.

