Getting a 503 when using CNAME to point www to the same server

I have a domain that works flawlessly with couldflare and a self hosted nginx instance though an Cloudflare Tunnel . However, when I add a CNAME record to point www to either or the tunnel, it does not work. I can resolve, but when I try to wget it I get a 503.

--2023-10-31 14:54:28--
Resolving (,, 2606:4700:3034::6815:4618, ...
Connecting to (||:443... connected.
HTTP request sent, awaiting response... 503 Service Unavailable
2023-10-31 14:54:28 ERROR 503: Service Unavailable.

When I wget alone, I see the request in nginx, when I use I don’t, so the request isn’t even being forwarded to the server. (This is with developer mode active to disable any caching). Both and are defined as part of the website in the nginx config.

When I looked for solutions all of them mention contacting the service provider, but that’s not very useful when I am the service provider. Or they mention that I need an A record, but I can’t set the tunnel as a destination with that.

I setup a redirect rule to check if that would fix it and yes, it does, but I would prefer to not waste those on something that shouldn’t be necessary in the first place, and I would prefer to keep the website with www when that is what was requested initially.

Thank you.

If you’re managing your tunnel through the Zero Trust Dashboard, you’ll need to add a new Public Hostname for the www subdomain if you haven’t already. If you were using the local ingress config, you’d need to add another ingress for the www subdomain there. (cnameing directly to the tunnel or to the root domain both go through the tunnel with the www hostname)

If www serves the same content as your apex ( you get penalized by search engines for having duplicate content. Generally you do want a redirect, ex: Redirecting www to domain apex · Cloudflare Pages docs

Thank you for explaining, this is what I was looking for.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.