How to create a CNAME Record for the root domain?

October 11, 2019 248 views
DNS

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 !

4 Answers

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

Hi @timoDjatomika,

Did you try putting example.com in instead of the @ sign?

I hope this helps!
Bud Manz

  • Hey. Thanks for the answer.

    Unfortunately that does not work.

    Then it will get example.com.example.com is an alias of foo.whatever.com

    :(

    • Okay, I think I understand now… so you are wanting example.com to point to another domain. In that case, the @ should reference the domain you want example.com to go to. For example, if you want foo.com to be pointed at bar.org, then bar.org would be the @. I am not entirely sure this is possible.

      Bud

Hey, @timoDjatomika

Could you please let me know if you want to set example.com as alias of foo.example.com or the other way around?

  • I simply wanna use cloudfront for my domain example.com. Therefore I have to create a CNAME Record that refers to another domain. Lets say foo.whatever.com.

    I just cloud create the record for www.example.com. But this is not what I want.
    The main content should be provided by example.com

    Also the CNAME’s for www.example.com and example.com are not the same.

    This should be somehow possible because of the tutorial described in my initial question. I just can’t use the “@” symbol (tried in different web browsers).

    Furthermore I successfully created a CNAME for example.com with cloudflare. So technically this shouldn’t be a problem.

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???)

Have another answer? Share your knowledge.