Understand and configure CNAME Flattening

CNAME Flattening allows a CNAME record to be created for the root domain without violating DNS specifications.

How CNAME Flattening works

Per DNS specifications (RFCs), a domain cannot have a CNAME record and another DNS record of a different type if both records would share the same name. DNS RFCs also require an MX record to correspond to a related A record and not a CNAME. This is problematic when you need a CNAME for your root (for example, a CNAME from example.com to example.herokuapp.com) but also need another type of DNS record at the root domain such as an MX record for mail delivery.

Typically, the aforementioned situation would cause problems receiving email. However, CNAME Flattening ensures the chain of CNAMEs is followed to an A or AAAA record to allow mail delivery while still adhering to DNS RFCs. The CNAME responses are cached and DNS TTLs are respected.

CNAME Flattening still works if the corresponding DNS CNAME record is "grey clouded" in the DNS app of the Cloudflare dashboard.

How to change settings for CNAME Flattening

CNAME Flattening cannot be disabled. By default, domains are setup to only flatten CNAME records at the root domain.

Domains on Pro, Business and Enterprise plans can either apply CNAME Flattening to CNAMEs at the root domain or for all CNAMEs within the domain. To flatten all CNAMEs in the domain, select Flatten all CNAMEs from the CNAME Flattening dropdown menu within the DNS app of the Cloudflare dashboard.