I followed some advices to point a domain to a Heroku app. The posts I'm talking about can be found here and here. From the command line I added the custom domains to my app

$ heroku domains:add www.myapp.com
$ heroku domains:add myapp.com

and then I added these configuration in my Gandi Zones

@ 300 IN A
@ 300 IN A
@ 300 IN A
imap 300 IN CNAME access.mail.gandi.net.
pop 300 IN CNAME access.mail.gandi.net.
smtp 300 IN CNAME relay.mail.gandi.net.
webmail 300 IN CNAME agent.mail.gandi.net.
www 300 IN CNAME myapp.herokuapp.com.
@ 300 IN MX 50 fb.mail.gandi.net.
@ 300 IN MX 10 spool.mail.gandi.net.

Everything works fine on http://www.myapp.com, but on the naked domain http://myapp.com I get an Application Error from Heroku.

How to solve this problem?


If your DNS provider allows, you should alias the naked domain ('@') with a CNAME to your app.

@ 300 IN CNAME myname.herokuapp.com.

Cloudflare allows this, but not all DNS providers do as it's apparently out-of-spec. Heroku relies on it. Using the Heroku IPs as A-records is deprecated and can cause issues.

  • We do support DNS at the root (CNAME domain.com) in our DNS settings. Users that decide to us CNAME at the root, however, should be aware that they will likely have issues receiving mail from some mail servers because of DNS RFC compliance (CNAME at root breaks this & users should use an A record wherever possible for the root domain). – damoncloudflare Jan 14 '14 at 19:59

Don't do that. Per DNS specifications, the CNAME record cannot co-exist with any other DNS type, that's the reason why CNAME is normally not allowed for the root domain.

Using a CNAME would prevent any other DNS record to work properly, excluding for example the possibility to configure MX records for your domain and thus preventing you from receiving email for that domain.

You would not be able to properly send emails as well, because TXT and SPF will be ignored.

The only way to solve the problem in this case is:

  1. Redirect the root domain to the www hostname (pointing the A record of the root domain to a redirection service)
  2. Use a DNS provider that allows a CNAME-like configuration for the root domain (by dynamically resolving and assigning A records to your root domain)
  3. Point the A record to one of the A records returned by your Heroku app name (not recommended, since they can change).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.