How to cname a domain
Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.
Last updated: April 4, 2026
Key Facts
- CNAME records map an alias to a canonical domain name.
- They are useful for pointing subdomains to services like CDNs or hosted platforms.
- CNAME records cannot be the primary record for a domain (e.g., example.com).
- The target of a CNAME record must be a fully qualified domain name (FQDN).
- Propagation of DNS changes can take anywhere from a few minutes to 48 hours.
What is a CNAME Record?
A CNAME record, short for Canonical Name record, is a type of resource record in the Domain Name System (DNS) that specifies an alias of a domain name. Essentially, it tells DNS servers that one domain name is an alias for another, canonical (true) domain name. This is different from other DNS record types like A records (which map a domain name directly to an IP address) or MX records (which handle mail exchange).
For example, if you have a website hosted on a platform like Heroku or AWS, and they provide you with a domain like myapp.heroku.com, you can use a CNAME record to point your custom subdomain, such as www.yourdomain.com, to myapp.heroku.com. When a user types www.yourdomain.com into their browser, the DNS lookup will follow the CNAME record, find the canonical name myapp.heroku.com, and then resolve that to the correct IP address provided by Heroku.
Why Use CNAME Records?
CNAME records offer several advantages:
- Simplifying Management: If the IP address of the canonical domain changes, you only need to update the DNS records for that canonical domain. All aliases pointing to it will automatically inherit the change without requiring individual updates. This is particularly useful when using third-party services that manage their own infrastructure and IP addresses.
- Pointing Subdomains to Services: Many web hosting providers, CDNs (Content Delivery Networks), and SaaS platforms require you to CNAME your subdomain to their domain. This allows you to use your own branded domain name while leveraging their services. For instance, pointing
blog.yourdomain.comtoyourdomain.wordpress.com. - Pointing Multiple Hostnames to the Same Server: While A records can point multiple hostnames to the same IP, CNAMEs offer a more flexible way to manage this, especially when the underlying server's IP might change.
- Using Wildcards: CNAME records can be used with wildcard DNS entries (e.g.,
*.yourdomain.com) to point all subdomains that don't have specific records to a common destination.
How to Create a CNAME Record
The process of creating a CNAME record typically involves logging into your domain registrar's control panel or your DNS hosting provider's interface. The exact steps can vary slightly depending on the provider, but the general procedure is as follows:
- Log in to your Domain Registrar/DNS Provider: Access your account where you manage your domain's DNS settings. Common providers include GoDaddy, Namecheap, Cloudflare, Google Domains, AWS Route 53, etc.
- Navigate to DNS Management: Look for a section labeled 'DNS Management', 'Zone Editor', 'Advanced DNS', 'Nameserver Settings', or something similar.
- Add a New Record: Find an option to 'Add Record', 'Create Record', or similar.
- Select Record Type: Choose 'CNAME' from the dropdown list of record types.
- Enter the Host/Name Field: This is the alias you want to create. For a root domain (e.g.,
example.com), you generally cannot use a CNAME. However, for subdomains likewww,blog, orshop, you would enter just that part (e.g.,www). Some interfaces might require the full subdomain likewww.yourdomain.com, while others use a special character like '@' for the root domain (though CNAMEs are problematic here). - Enter the Value/Target/Points To Field: This is the canonical domain name that the alias will point to. It must be a fully qualified domain name (FQDN) and cannot be an IP address. For example,
ghs.googlehosted.comoryour-app.herokuapp.com. - Set TTL (Time To Live): The TTL determines how long DNS resolvers cache the record. A lower TTL means changes propagate faster but can increase DNS lookup load. A common default is 3600 seconds (1 hour).
- Save the Record: Confirm and save the new CNAME record.
Important Considerations and Limitations
While CNAME records are powerful, they come with specific rules and limitations:
- Root Domain Restriction: A CNAME record cannot be the primary DNS record for a domain (the record associated with the apex or root domain, often represented by '@'). This means you cannot use a CNAME for
example.comitself. This is because the root domain must have other essential records like SOA and NS records, which cannot coexist with a CNAME. You can typically use an A record for the root domain pointing to an IP address, and then potentially use a CNAME for a subdomain likewwwpointing to the root domain or another service. Some DNS providers offer workarounds like 'CNAME flattening' or 'ALIAS' records (proprietary to some providers like AWS Route 53) that mimic CNAME behavior at the root level. - Target Must Be a Domain: The value you enter for a CNAME record must be another domain name, not an IP address.
- Chaining Limitations: While you can chain CNAMEs (e.g.,
alias1.example.comCNAME toalias2.example.com, which then CNAMEs tocanonical.example.com), excessive chaining can lead to slower lookup times and potential issues. Most DNS specifications recommend a maximum of 2-3 CNAME records in a chain. - Propagation Time: After creating or modifying a CNAME record, it takes time for these changes to propagate across the global DNS network. This process, known as DNS propagation, can take anywhere from a few minutes to 48 hours, although it's often much faster.
CNAME vs. Other DNS Records
Understanding how CNAMEs differ from other common DNS records is crucial:
- A Record: Maps a domain name directly to an IPv4 address. Essential for the root domain.
- AAAA Record: Maps a domain name directly to an IPv6 address.
- MX Record: Specifies the mail servers responsible for accepting email for a domain.
- TXT Record: Used to provide arbitrary text information, often for verification purposes (like SPF, DKIM records).
In summary, CNAME records are a flexible tool for managing domain aliases, particularly for subdomains pointing to external services or for simplifying DNS management when underlying IP addresses might change. Always remember the restriction on root domains and the time required for DNS propagation.
More How To in Technology
- How To Learn Programming
- How to code any project before AI
- How to make my website secure
- How do I deal with wasting my degree
- How to build a standout portfolio as a new CS grad for remote freelance work
- How do i learn programming coding
- How to fetch ecommerce data
- How to start a UI/UX career
- How to create a test map for a Bomberman game in C++ with ncurses
- How to cut your own hair
Also in Technology
More "How To" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
- CNAME record - WikipediaCC-BY-SA-4.0
- What is a CNAME record? | Cloudflarefair-use
- Understanding Domain Names | ICANNfair-use
Missing an answer?
Suggest a question and we'll generate an answer for it.