Correct DNS for Cloudflare Pages?

Hi everyone. I’m trying to set up cloudflare pages with a custom domain I own through namecheap. I have it mostly set up, but I think that something is falling apart with the DNS. So far I have managed to:

  1. Purchase the domain through namecheap (and set up email redirect through them, which may or may not be relevant)

  2. Connected a github repo to Cloudflare Pages

  3. Successfully hosted the site on xxx.pages.dev

  4. Configured the domain to use Cloudflare’s nameservers

However, at this point the custom domain will not resolve to the site.

I have one A record with a name of the custom domain and the content pointing to an IP address I didn’t generate.

I have one CNAME record with the name WWW and the content of the Coudflare-generated URL that resolves to the site (xxxx.customdomainname.pages.dev)

I have 6 MX records with the name of the custom domain and the content pointing to various registrar-servers.com sites

I have one TXT record with the name of the custom domain and the content pointing to v-sfp1…

I have a sneaking suspicion that this could be as easy as updating the CNAME record, but for the life of me I can’t figure out what to update it to.

Any suggestions would be most appreciated.

thanks!

Hi,

You can use a CNAME for the Zone Apex (@).

Point it to the pages custom domain and make sure the apex domain is also added as a custom domain on the pages project.

You can remove the A record with the IP that was generated (you won’t need it with a CNAME at the zone apex)

Thanks!

When I tried to create a CNAME with @ as the name and the cloudflare-created domain for the site as the content, I got a message that “Another record shares the same name, so we’ve applied CNAME flattening.” As a result, the name in the record is set to the custom domain and the content is set to the cloudflare-created domain.

I also got a message (warning?) that I needed to “Add an A, AAAA, or CNAME record for www so that” www.[customdomain.org] will resolve. I created a new entry with www as the name and the cloudflare-created domain as the content.

I also removed the A record.

The warning disappeared but the site still won’t resolve - I get an Error 522.

Any other ideas?

Thank you!

Can you post a screenshot of the DNS tab (you can blank out the hostnames/domain)

Just so I can see exactly what records exist

Totally - thank you again:

The notice next to the second CNAME entry is about the flattening.

Change the content of the “WWW” CNAME to match the CNAME record at the zone apex (the one with the CNAME flattening)

Then just make sure both are added to the pages project as custom domains.

It may take a few minutes to issue the SSL certificate for the pages custom domains but after that it should work :slight_smile:

N.B You can CNAME the WWW subdomain to the zone apex but there is a bug where it doesn’t apply some settings unless you CNAME directly to the pages custom domain (just to be aware)

Like this?

It still isn’t working, but I know it can take a bit of time to propagate through the system.

thank you

That looks absolutely fine and should work without issues.

It may be a propagation issue.

If you post a screenshot of the custom domains tab on the pages project (again you can blank out the hostnames) then we can verify that’s correct and ensure it is a propagation issue.

Cloudflare IP’s are available at IP Ranges | Cloudflare

Strangely, when I go to the custom domain tab I get prompted to set up the custom domain (again):

Should I just go through the process again or wait to see if the propagation kicks in?

Yeah, that may explain why it doesn’t work.

Try adding them again :slight_smile:

I did it and it kicked me out to the same page BUT before it did it indicated that it was updating the CNAME record. It changed the zone apex record from what it was - #####.projectname.pages.dev to just projectname.pages.dev. I went in to make the same change to the www record and everything seems to be working now.

Thank you so much!

No problem :slight_smile:

If you have any more questions about pages, feel free to join the Discord community