Domain does not resolve for non-www URL in a Heroku-Cloudflare Configuration

I have an app deployed on Heroku and using Cloudflare as my DNS Server. I have generated an SSL Certificate on Cloudflare and successfully uploaded it on Heroku. I have obtained my DNS Target from Heroku and created the following two CNAMEs on Cloudflare:

CNAME "Proper DNS Target from Heroku" Proxied
CNAME www "Proper DNS Target from Heroku" Proxied

I have also created the following rule on Cloudflare:*
Forward URL to$1

The URL resolves properly. However, it doesn’t when I do not use the “www” (i.e. ).

I have tried numerous different configurations suggested online, but none worked.

Any idea?

Without seeing your DNS setup or the website domain, it’s hard to be able to suggest anything other than recommending to go over one of the guides (i.e & make sure you’ve followed every step.

You should have two different CNAME targets from Heroku which need to be added to the right record in Cloudflare’s DNS.

Thank you @KianNH Yes, I have carefully followed that guide and did obtain 2 different CNAME Targets from Heroku and used the proper ones for each corresponding CNAMEs on Cloudflare, but nothing seems to work (proof that I haven’t mixed them is that the URL using the www works). I will look at it again. Thanks again.

I vaguely recall someone else having the same kind of issues in the past (setting up @ and www for a Heroku site) but I can’t really remember what their solution ended up being.

When you say that the root domain doesn’t work, what exactly does ‘not working’ entail?

Can you visit the site but get a Heroku ‘not found’ or are you getting a Cloudflare error page?

I am getting “This site can’t be reached”. If I use try curl -I, I get “Could not resolve host”. Thus, the problem seems to be on the Cloudflare side.

Just to sanity check, try these two commands:


I don’t actually know how it’s possible (since entering instead of @ will treat it as if you meant @ in the UI) but I’ve seen it before.

1 Like

Yes, this was the problem!!! Although I wasn’t seeing a duplicate domain name in the CNAME Field, it has answered on both dig commands. After editing the CNAME using only “@”, the non-www url started resolving. I must have initially entered the domain name when creating the CNAME. I thank you very, very much! Have a Great day.

1 Like

I’ve never actually been able to recreate it myself - no matter how I do it, new record or changing an existing one, entering as the record name is put on rather than like in your case.

Kian which software u use to coomunicate dig command

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