Question

How to create a CNAME Record for the root domain?

Hello.

My question is how to create a CNAME Record for the root domain “example.com”.

I’ve already looked at this tutorial here: https://www.digitalocean.com/docs/networking/dns/how-to/manage-records/

They wrote that I should use the “@” sign. Unfortunately when I try the “@” sign in the Hostname field I get the error: “Invalid Hostname”.

I wanna create the following alias: example.com is an alias of foo.whatever.com

Thanks for the help !


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Hey,

The reason you can’t enter it in the interface is because the DNS standard doesn’t allow CNAME for the root record. Root record always has to be A.

See more:

https://www.freecodecamp.org/news/why-cant-a-domain-s-root-be-a-cname-8cbab38e5f5c/

To consolidate your records people usually go the other way… foo.example.com is an alias of example.com

I’ve this Option in Namecheap…

But in Digital Ocean, they won’t allow us to Create CNAME for Root Domain.

if Your Domain is in Namecheap or any Domain Panel…

And Hosting is in Digital Ocean…

Then, I would suggest you to…

Remove Your Digital Ocean NS1, NS2, NS3 DNS Values ( Name Servers ) from Domain Panel…

Then, Create A Records to Your Digital Ocean Server IP

Also, Create CNAME from your Domain Panel…

Majority of the People, Including me…

Buying Domain from Namecheap, and from there Creates Name Server for Digital ocean to point Domain to the DO Server.

And Then, We Create All Values in Digital Ocean Panel…

That’s Good in some cases, but when we face issues like this… the old school method is Good…

According to this blog post: https://www.freecodecamp.org/news/why-cant-a-domain-s-root-be-a-cname-8cbab38e5f5c/

I shouldn’t use the CNAME for the root domain. Some DNS Providers implemented a workaround (e.g. Cloudflare) so thats the reason why it worked for my other domain (using Cloudfront to host a website and Cloudflare as my DNS Provider).

I think digitalocean decided not to implement such a workaround because of reasons that I don’t know (maybe they wanna stick to a standard???)