www.yourdomain.com loads fine. yourdomain.com (the apex / root) returns “this site can’t be reached.” Or vice versa. Users typing the shorter version get an error and bounce. The fix has two parts that often get conflated: (1) both versions must have working DNS records pointing to your host, and (2) a redirect rule must consolidate visitors to the one canonical version. Many people set only DNS or only the redirect and wonder why one version doesn’t work.
This guide walks through both parts and the per-platform implementation.
Common causes
Ordered by hit rate, highest first.
1. Only one DNS record set
You configured A for the apex but no CNAME for www. Or you set www CNAME but forgot the apex. The unconfigured side returns NXDOMAIN.
How to spot it:
dig yourdomain.com +short
dig www.yourdomain.com +short
If one returns nothing, that’s the missing record.
2. Both DNS records set but no redirect
Both versions resolve and load the site, but they serve content independently. SEO sees this as duplicate content; users get inconsistent URLs.
How to spot it:
curl -sI https://yourdomain.com | head -3
curl -sI https://www.yourdomain.com | head -3
If both return 200 (not 301 to the other), redirect is missing.
3. Apex tried to use CNAME (RFC violation)
You set CNAME at the apex (root domain). Strict DNS providers reject this; permissive ones accept it but cause subtle bugs (MX records won’t work, conflicts with TXT).
How to spot it: DNS provider error like “CNAME cannot coexist with other records at apex.” Or just silent partial failure.
4. Hosting platform requires specific apex / www convention
Vercel apex must be A 76.76.21.21. Netlify is similar. If you put apex IP for one host while serving with another, mismatch.
How to spot it: Compare your A record IP to your platform’s documented apex IP.
5. Redirect set wrong direction or in code, not platform
You added a redirect in your app code (e.g., React Router) but it only fires after page load. SEO and direct hits still see the wrong canonical.
How to spot it: Redirect happens after JS loads, not on initial response. Should be HTTP 301 at the platform level.
6. www subdomain not provisioned on host
You added yourdomain.com to Vercel but not www.yourdomain.com. The CNAME points but the host returns 404.
How to spot it: Platform dashboard → domains list. If only one is listed, add the other.
Shortest path to fix
Step 1: Pick a canonical
Either apex or www. Commit. Common choices:
- Apex (
yourdomain.com): shorter, more modern. Required for some platform features. - www (
www.yourdomain.com): traditional, easier with CDNs (CNAME at www avoids apex CNAME issue).
Document the choice somewhere obvious so you don’t second-guess.
Step 2: Set both DNS records
For Vercel + apex as canonical:
A @ 76.76.21.21
CNAME www cname.vercel-dns.com
For Vercel + www as canonical:
CNAME www cname.vercel-dns.com
A @ 76.76.21.21 (still needed for redirect)
Both must exist regardless of canonical choice.
Step 3: Add both domains to your host
In Vercel / Netlify / Firebase dashboard, add both yourdomain.com and www.yourdomain.com. The platform then knows to handle both.
Many platforms auto-redirect non-canonical → canonical once both are added. Others require explicit config.
Step 4: Configure the redirect at platform level
Vercel — Domain settings → set one as primary; Vercel auto-redirects the other.
Netlify — Domain management → set primary; same auto-redirect.
Firebase — Both domains can be added but redirect must be in firebase.json:
{
"hosting": {
"redirects": [{
"source": "**",
"destination": "https://yourdomain.com/:1",
"type": 301
}]
}
}
(Per-domain config differs; this is the gist.)
Step 5: Verify
# Non-canonical should 301 to canonical
curl -sI https://www.yourdomain.com | head -5
# Expect: HTTP/2 301, Location: https://yourdomain.com/
If both return 200, redirect isn’t configured.
Step 6: Update canonical in <head> and JSON-LD
Even with redirect, your HTML should self-canonical to the canonical version:
<link rel="canonical" href="https://yourdomain.com/article/" />
Not https://www.yourdomain.com/article/. Match your chosen canonical.
Prevention
- Choose canonical at launch — don’t flip later (causes Search Console churn).
- Set up both DNS records (apex A and www CNAME) on day 1.
- Add both domains to your host immediately.
- Verify with curl that the redirect returns 301, not just a JS redirect.
- Self-canonical in HTML matches your chosen canonical.
Related
- Root vs www domain
- www and non-www both open separately
- Duplicate domain versions indexed
- A vs CNAME confusion
Tags: #Troubleshooting #DNS #Debug