Have you encountered error 522 connection timed out? Do you know why this error happens and how to solve it? In this post, MiniTool Partition Wizard will talk about these questions.
What Causes HTTP Error 522 Connection Time Out
When you use browsers to visit web pages, you may encounter many errors, including the HTTP error 522 connection timed out.
What does this error mean? The preceding ‘5’ indicates a server error and the following ‘2’ indicates that the server error has occurred in conjunction with Cloudflare. The error 522 means that it occurs whenever the TCP handshake between the web server and Cloudflare fails.
Cloudflare is a company that provides customers with content delivery network (CDN) based on reverse proxy and distributed domain name resolution service. Using tits global anycast network, Cloudflare can help protected sites resist network attacks, ensuring that the site is always online and improving the performance and loading speed of the site.
When someone visits a Cloudflare-enabled website, a connection is established between Cloudflare and the website’s origin server. To establish a connection, TCP uses the three-way handshake shown as follows:
- Cloudflare sends three SYN packets to the origin server.
- In response, the origin server replies with a SYN+ACK.
- Finally, Cloudflare sends an ACK back to the origin server.
But the error 522 connection timed out will occur, if the following 2 cases happen:
- Before a connection is established, the origin web server does not return a SYN+ACK to Cloudflare within 15 seconds of Cloudflare sending a SYN.
- After a connection is established, the origin web server doesn’t acknowledge (ACK) Cloudflare’s resource request within 90 seconds.
Then, what causes the error 522? The possible reasons are as follows:
- Cloudflare IP addresses are rate limited or blocked in .htaccess, iptables, or firewalls. Confirm your hosting provider allows Cloudflare IP addresses.
- An overloaded or offline origin web server drops incoming requests.
- Keepalives are disabled at the origin web server.
- The origin IP address in your Cloudflare DNS app does not match the IP address currently provisioned to your origin web server by your hosting provider.
- Packets were dropped at your origin web server.
How to Fix Error 522
If you have received the error 522 connection timed out, you can try the following methods to fix the problem.
- Optimize server capacity: You should keep an eye on the traffic development of your web project using analysis software, so that you can identify bottlenecks and upgrade the hardware setup of the hosting environment and make flexible cloud hosting solutions to scale resources with pinpoint accuracy.
- Check IP filtering: Check if Cloudflare’s IP addresses are blocked by firewall settings, iptables, and other filtering applications. A list of the addresses used by the CDN service provider can be found on the official website. Please whitelist these Cloudflare addresses.
- Customize DNS/IP settings: Note down the current IPv4 and IPv6 addresses of the web server. Switch to the Cloudflare configuration menu and select the domain causing the error. Click on the menu item ‘DNS’ and then enter the recorded web addresses in the corresponding DNS records.
- Activate ‘keepalive’ message: If ‘keepalive’ is switched off or too few possible requests are defined, you can correct this in the respective configuration file of the web server (e.g. in httpd.conf for Apache servers).
- Contact Cloudflare-Support: If you have no idea about how to deal with the error, please contact Cloudflare Support for help.