How to fix Error 522 on Cloudflare

How to fix Error 522 on Cloudflare

In my case, I realized that I had two A records set-possibly added by Cloudflare.

The Cloudflare team did a great job sharing the possible causes of the error and how you could solve them. I have quickly outlined those below;

Causes of the 522 error

Error 522 occurs when Cloudflare times out contacting the origin web server. Two different timeouts cause HTTP error 522 depending on when they occur between Cloudflare and the origin web server:

  1. 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.
  2. After a connection is established, the origin web server doesn't acknowledge (ACK) Cloudflare's resource request within 90 seconds.

Source: Cloudflare support

This Quora post covered more reasons for the connection timed-out message.

How I resolved the error

In my case, I realized that I had two A records set. The second one was automatically added when my domain was in the redemption grace period - I had not renewed my domain in time.

Cloudflare had sent me an email earlier saying that my nameservers were no longer pointing to Cloudflare and that my DNS records would be removed entirely from the Cloudflare system in 7 days. This justifies why I found new DNS records - possibly added by Cloudflare.

However, when I tried to recreate this problem by adding a second A record, my application was running just fine. I am not sure why I was unable to get the same error.

Great week ahead!