When configuring a Heroku app with custom domains, developers often encounter a fundamental DNS limitation: you cannot have both a CNAME and TXT record for the same subdomain. This creates problems when you need:
- CNAME:
www.example.com → example.herokuapp.com
- TXT: Domain verification records (Google Search Console, Yandex Metrika, etc.)
The DNS protocol treats CNAME records specially - they make all other record types for that subdomain invalid. From RFC 1034:
If a CNAME RR is present at a node, no other data should be present
Option 1: Verify at Root Domain
Configure verification TXT records at the root (example.com
) while keeping CNAME at www
:
example.com. TXT "google-site-verification=ABCD1234" www.example.com. CNAME example.herokuapp.com.
Option 2: Use ALIAS/ANAME Records
Some DNS providers (Cloudflare, DNS Made Easy) offer synthetic records that resolve like CNAME at the root:
example.com. ALIAS example.herokuapp.com. example.com. TXT "yandex-verification: 5678EFGH"
Option 3: Domain Forwarding
For Heroku specifically, you can:
- Set root domain as ALIAS to
www
- Keep verification TXT at root
- Redirect naked domain in Heroku:
// In Heroku app code (Node.js example) app.get('/', (req, res) => { if(req.hostname === 'example.com') { return res.redirect(301, 'https://www.example.com' + req.path); } });
For Google Search Console verification via DNS:
// Traditional TXT record google-site-verification=6P08Ow5E-8QZq1NdQ8JzQk1JQN3kX8mJwK9pLz0XrY4 // Alternative meta tag verification <meta name="google-site-verification" content="6P08Ow5E-8QZq1NdQ8JzQk1JQN3kX8mJwK9pLz0XrY4" />
Use dig to verify records don't conflict:
dig example.com TXT +short dig www.example.com CNAME +short
When configuring a Heroku app with custom domains, developers often encounter a fundamental DNS limitation: CNAME records cannot coexist with other record types (like TXT) at the same subdomain level. This creates problems when you need both domain aliasing (CNAME) and service verification (TXT).
The standard Heroku setup requires:
www.example.com. 300 IN CNAME example.herokuapp.com.
But verification services like Google Search Console demand:
www.example.com. 300 IN TXT "google-site-verification=abc123"
www.example.com. 300 IN TXT "yandex-verification: def456"
Option 1: Domain Root Verification
Verify at the apex domain (example.com) while keeping www CNAME:
example.com. 300 IN TXT "google-site-verification=abc123"
www.example.com. 300 IN CNAME example.herokuapp.com.
Option 2: Alternative Verification Methods
Use HTML file verification if your app supports static files:
# In your public/ folder
googleabc123.html
yandex_metrika.html
For Heroku apps, consider these DNS setups:
# Cloudflare example using CNAME flattening
example.com. 300 IN A 192.0.2.1
www.example.com. 300 IN CNAME example.herokuapp.com.
example.com. 300 IN TXT "v=spf1 include:_spf.heroku.com ~all"
Remember that DNS changes may take up to 48 hours to propagate globally. Always verify with:
dig TXT example.com +short
dig CNAME www.example.com +short
For cscombo.com mentioned in the question, the working configuration would be:
cscombo.com. 300 IN TXT "google-site-verification=abc123"
cscombo.com. 300 IN TXT "yandex-verification:def456"
www.cscombo.com. 300 IN CNAME cscombo.herokuapp.com.
Then configure Heroku to handle both domain variants:
heroku domains:add cscombo.com
heroku domains:add www.cscombo.com