My site works with www.example.com but not with example.com

My website is hosted using Cloudflare Pages and the domain provider is of course Cloudflare.
I would like my site to be accessible using example.com. But that does not work and I get a "Connection timed out Error code 522”.

I have incorporated the suggestions from Cloudflare documentation and similar issues in my DNS records. Can someone please help fix my issue?
Thanks in advance!

The A and AAAA records you have set are used if you are trying to set up a redirect from example.com to www.example.com, either with a Page Rule or Redirect Rule. Have you actually set up the redirect?

2 Likes

Thanks @sjr for your quick response.
I have not setup redirects. From the documentation I had assumed that they are useful for sub-domain related use cases. But maybe I am wrong.
Shall I follow the steps in the tutorial here?

Just an additional question - would removing A or AAAA records help? Would only CNMAE record with some alternate config help? Or should I go for redirects so that example.com works.

Thanks again!

You can either…

  • Redirect www to the domain as you are part-way through doing
    or
  • Add example.com as a custom domain to Pages as you did with www.example.com (the relevant DNS records will be automatically added to the DNS so remove the A/AAAA records you set)

I personally feel the first one is better as it means your site it available on a single hostname which can be better for SEO and a consistent link for users.

1 Like

Thanks @sjr again for prompt response. So by option 1 you mean this tutorial linked earlier?
If yes, I will then complete it and report back the progress.

Yes, follow that tutorial.

1 Like

voila! it works. Thanks for your help.
Should I keep the CNAME record as it is or do you recommend I make any changes based on Cloudflare best practices?

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.