Why does www work but my domain without www doesn’t?
One version of your address works and the other shows an error, the wrong site, or a certificate warning. The two names are configured separately at every layer, so one can be right while the other is wrong. This guide finds the layer where they differ.
Two names, four places
example.com and www.example.com are different DNS names. Nothing connects them automatically. For both to work, each has to be right in four places: a DNS record for each name; each name added to the host’s project; each name covered by the certificate; and a redirect from one to the other so visitors end up in one place. One name can be complete while the other is missing at any of the four, which is why “www works but the plain domain doesn’t” (or the reverse) is so common and so easy to fix once you know which place.
Which failure do you have?
Open the failing name in a private window and note what happens:
| What the browser shows | The layer that’s wrong |
|---|---|
| “This site can’t be reached”, “server not found”, or the address never resolves | DNS: the name has no record, or a wrong one |
| A page from the host saying the domain isn’t configured, a 404 from the host, or a different site entirely | Host: DNS points at the host, but the host doesn’t know this name |
| A certificate or “connection not private” warning, with the site loading if you click through | Certificate: the name isn’t on the certificate yet |
| The registrar’s parking page, or a redirect that lands on http rather than https | Redirect: registrar forwarding is standing in for a DNS record |
| Too many redirects | Redirect loop between the names, or a proxy SSL mode issue |
The DNS layer: the apex and www take different records
The bare domain, called the apex and written @ in DNS panels, can’t carry an ordinary CNAME record alongside its other records; that’s a rule of DNS itself. So hosts ask for an A record at the apex, pointing at an address such as Vercel’s 76.76.21.21 or Netlify’s 75.2.60.5, or an ALIAS or flattened CNAME if your DNS provider offers one. The www name is an ordinary subdomain and takes a CNAME to the host’s name. Because the two records look different, people often set one and assume the other follows. It doesn’t.
Check both with a lookup tool: A and AAAA for the apex, CNAME for www. The DNS-change guide explains how to query the authoritative nameservers so you’re not looking at a cached answer. The name that fails will have no record, the wrong record, or an old record left over: a common one is a stale AAAA record at the apex sending phones to the old host, which Netlify’s troubleshooting page singles out because its load balancer doesn’t support IPv6, and Vercel doesn’t support IPv6 either. Netlify also warns that multiple A records at the apex cause certificate failures. Fix the record for the failing name only, and remove what shouldn’t be there.
The host layer: both names must be added to the project
DNS pointing at a host only gets the request to the host’s door. The host then needs to know which project the name belongs to. If only one name was added to the project, the other arrives at the host and gets a “domain not configured” page, a 404, or whatever default the host serves. Open the project’s domain settings and confirm both names are listed. Vercel prompts you to add www when you add the apex and vice versa; Netlify adds both automatically when you add either; Cloudflare Workers needs each custom domain added, and Pages needs each name added too. Add the missing one and give the host a minute to verify it.
The certificate layer: the name has to be on the certificate
Hosts issue certificates per name they know about, and only once that name’s DNS points at them. So a name added late, or whose DNS was fixed late, gets its certificate late. Netlify says outright that DNS has to be configured in advance for every alias it should include on the certificate. The symptom is a security warning on one name and a clean padlock on the other. Wait for the host’s domain screen to show the certificate as issued for the second name; if it stays pending, the HTTPS guide has the causes, including CAA records and Cloudflare’s proxy.
The redirect layer: redirects aren’t a substitute for DNS
Two distinct mistakes live here. First, registrars offer “domain forwarding”, which makes the apex redirect to www by pointing the apex at the registrar’s own server. It works for http, but the registrar usually can’t serve a certificate for your domain, so https://example.com fails while https://www.example.com works. The fix is to give the apex a real record at the host and let the host do the redirect.
Second, a redirect loop: the apex redirects to www and something redirects www back, or Cloudflare’s Flexible SSL mode bounces between http and https with a host that forces https. Set the redirect in one place, the host, and if Cloudflare proxies the record, use its Full (strict) mode.
How Vercel, Netlify and Cloudflare handle both names today
- Vercel asks for an A record at the apex and a per-project CNAME at
www, prompts you to add the second name when you add the first, and lets you set which one redirects to the other with a “Redirect to” option. It recommendswwwas the primary. It doesn’t support IPv6, so there should be no AAAA record. - Netlify asks for an ALIAS to
apex-loadbalancer.netlify.comor an A record to75.2.60.5at the apex and a CNAME to yournetlify.appaddress atwww. Adding either name adds both, and whichever you set as primary gets the other redirected to it. With external DNS it recommendswwwas primary. - Cloudflare can flatten a CNAME at the apex when it holds your DNS, so the apex can point at a name. For a Worker custom domain, Cloudflare creates the records itself, one per name you add. For Pages,
wwwcan be a CNAME from any provider but the apex has to be a zone on Cloudflare.
Pick one canonical version and redirect the other
Search engines and shared links should land on one address. Choose it once. Both names still need DNS records and both need to be on the certificate, so that whichever a visitor types, they’re redirected securely to the one you chose. If your DNS is at an outside provider, the hosts’ own advice is to make www primary, because its CNAME can follow the host’s network while the apex A record can’t. If the site has always been on the bare domain and links point there, keep it; the point is consistency, not which one.
Checklist
- The apex has an A record (or ALIAS) to the host’s value, and no leftover AAAA or CNAME.
- www has a CNAME to the host’s name, and no leftover A record.
- Both names are listed in the host’s domain settings.
- The host shows a certificate issued for both names.
- One name is set as primary at the host, and the other redirects to it over https.
- No registrar forwarding is standing in for the apex record.
- If Cloudflare proxies either record, the host allows that and the SSL mode is Full (strict).
Sources
The rules and product behaviour described above were checked against these pages when the guide was last updated. If something here has changed, these are the places to look.
- Domain names: concepts and facilities, RFC 1034 §3.6.2 · IETF
- Adding a custom domain · Vercel
- Deploying and redirecting domains · Vercel
- Domains troubleshooting · Vercel
- Working with DNS · Vercel
- Configure external DNS for a custom domain · Netlify
- Manage multiple domains · Netlify
- HTTPS (SSL) · Netlify
- Troubleshoot SSL and HTTPS · Netlify
- CNAME flattening · Cloudflare
- Custom domains for Workers · Cloudflare
- Custom domains for Pages · Cloudflare
- Too many redirects · Cloudflare
- Encryption modes · Cloudflare
Keep going
Related guides
Or go back to the overview of what owning your site means, which ties all of these together.
How to connect a custom domain to your website without breaking email
Connect a domain to a new host by changing only the website records: apex and www, A, AAAA and CNAME, provider verification records, when nameservers must change and when they mustn’t, why MX, SPF, DKIM and DMARC stay untouched, Cloudflare proxying, conflicting provider instructions, and how to verify the site and email afterwards.
About a 10 minute read
Why is my website not showing after I changed DNS?
A diagnostic for a site that isn’t appearing after a DNS change: how to tell caching from a configuration that will never work, then checks for a wrong record, the wrong DNS provider, nameservers pointing elsewhere, apex and www mismatches, leftover records, stale AAAA records, proxying, pending verification and pending certificates.
About a 9 minute read