Why a DNS Alias Change Can Break a Hostname
In this article
A DNS alias change can break a hostname when the old alias is still cached, when the new alias points to a resource that rejects the hostname, or when the change invalidates a certificate or service binding that depended on the old name. The break is rarely the DNS record itself—it is usually a mismatch between what the new record resolves to and what the software, client, or security layer expects. Below is the background, the mechanics, and the practical steps to diagnose and prevent these failures.
What a DNS Alias Actually Is
A DNS alias is a record that maps one name to another name, rather than directly to an IP address. The two common types are:
- CNAME (Canonical Name) – maps an alias like
www.example.comto a canonical name likeexample.comor to a CDN hostname. The resolver must then look up the target name to get the final IP address. - ALIAS / ANAME – a non-standard record offered by many DNS providers that behaves like a CNAME but can be used at the zone apex (e.g.,
example.comitself). It returns the target’s IP addresses directly.
When you change an alias, you are changing the target name. That sounds simple, but every layer between the user’s browser and your server has its own copy of DNS data, and each layer may hold onto the old answer for a different length of time.
How DNS Resolution and Caching Work
When a client asks for www.example.com, the resolver (usually the operating system or the local router) follows a chain:
- Check the local cache.
- Ask the recursive resolver (ISP or public DNS like 8.8.8.8).
- That resolver may have its own cached copy.
- If not, it queries the authoritative nameserver for the zone.
Each response includes a TTL (time to live) in seconds, telling the resolver how long to keep the answer. When you change an alias, the old record may still be served from caches until the TTL expires. If you set a long TTL (e.g., 86400 seconds = 24 hours), some users will continue to hit the old target for up to a day after the change. If the old target is still running, the change appears to “work” for those users—but if the old target is decommissioned, they get connection errors.
Why the New Target May Reject the Hostname
Even after DNS propagates, the new target often rejects requests because the Host header (the hostname the browser sends) does not match what the server expects. This is the most common cause of a “broken” hostname after an alias change. Consider these scenarios:
- Web server virtual hosts: Apache or Nginx serves different sites based on the Host header. If the new target only has a virtual host for
internal.example.comand you pointwww.example.comto it, the server returns a default page or a 404. - TLS/SSL certificates: The certificate on the new target must include the alias name. If it only covers
internal.example.com, the browser shows a certificate name mismatch warning and blocks the connection. - Application-level redirects: Many apps are configured with an “allowed host” or “base URL”. If the app does not recognize the new hostname, it may redirect to the canonical name, causing a redirect loop or a 400 error.
- CDN or load balancer rules: A CDN may route based on the Host header. If the alias is not configured in the CDN, the request falls to a default origin that may not have the content.
Common Breakage Patterns and Examples
Here are three realistic scenarios that illustrate how an alias change breaks a hostname:
- Scenario 1 – CNAME to a new CDN: You change
www.example.comfrom a CNAME toorigin.example.comto a CNAME tocdn.example.net. The CDN is not configured to acceptwww.example.com, so it returns a 421 Misdirected Request. The DNS is correct, but the CDN rejects the hostname. - Scenario 2 – Alias to a new server with a different certificate: You change the ALIAS record for
example.comto point tonewserver.example.net. The new server has a certificate fornewserver.example.netonly. Users get a “Your connection is not private” warning. - Scenario 3 – Email hostname change: You change the MX record’s target from
mail.old.comtomail.new.com. If the new mail server does not accept mail for your domain (because it is not configured as an accepted domain), mail bounces with a “Relay access denied” error.
How to Diagnose a Broken Hostname After an Alias Change
If a hostname breaks after a DNS change, work through these steps in order:
- Check what the DNS actually returns – use
digornslookupto query the authoritative nameserver directly (e.g.,dig @ns1.example.com www.example.com) to see the new target. Then query a public resolver like 8.8.8.8 to see if it still has the old cached answer. - Check the target’s response – use
curl -I https://www.example.comto see the HTTP status and headers. Look for a redirect to a different hostname, a 421, or a certificate error. - Verify the TLS certificate – use
openssl s_client -connect target:443 -servername www.example.comto see if the certificate includes the alias name in its Subject Alternative Name (SAN). - Test with the target IP directly – add a temporary entry in your hosts file mapping the alias to the new IP. If the site works with the hosts entry but not without it, the issue is DNS propagation or a resolver-specific problem.
- Check the server logs – look for “host not found” or “invalid Host header” entries in the web server or application logs.
How to Prevent Breakage (and What to Do if It Happens)
Prevention is mostly about planning and testing before you change the record:
- Lower the TTL before the change – set the TTL of the record to 300 (5 minutes) at least 24 hours before the change. This ensures that old cached answers expire quickly.
- Test the new target with the alias name – before changing DNS, use a hosts file entry to point the alias to the new target. Verify the site loads, the certificate is valid, and the application accepts the hostname.
- Keep the old target alive – for at least one full TTL period after the change, keep the old server running and responding. This handles users who still have the old IP cached.
- If it breaks, revert quickly – the fastest fix is to change the alias back to the old target. The old record will be cached again, but since the old target is still alive, users recover within the TTL.
Frequently Asked Questions
Why does my site work on my phone but not on my computer after a DNS change? Different devices and networks use different DNS resolvers. Your phone may be using a mobile carrier’s resolver that has already picked up the new record, while your computer’s ISP resolver still has the old cached answer. Wait for the TTL to expire or flush the DNS cache on the affected device.
What is the difference between a CNAME and an A record? An A record maps a hostname directly to an IPv4 address. A CNAME maps a hostname to another hostname, and the resolver must then look up that target’s A or AAAA record. CNAMEs are useful for aliasing but cannot be used at the zone apex (the bare domain) because that would create a conflict with the SOA and NS records.
How long does a DNS change take to propagate? It depends on the TTL of the old record. If the old TTL was 3600 seconds (1 hour), most resolvers will update within an hour, but some ISPs ignore TTLs and cache longer. Global propagation can take 24-48 hours in practice, especially for less popular domains.
Can I use a CNAME for my root domain? Not with standard DNS, because the root domain already has SOA and NS records, and a CNAME cannot coexist with other records. Use an ALIAS/ANAME record (if your DNS provider supports it) or an A record pointing to the target’s IP address.
Why do I get a certificate error after changing a CNAME? The certificate on the new target must include the hostname you are using. If the certificate only covers the target’s own name, the browser will reject it. You need to either add the alias to the certificate or use a wildcard certificate that covers both names.
What should I do if I changed the alias and now email is bouncing? Check the MX record’s target. The mail server at the new target must be configured to accept mail for your domain. If it is not, add your domain to the accepted domains list on that server. Also verify that the server’s hostname and certificate match the MX target to avoid TLS errors.