Issue
There are several different CNAME targets for configuring DNS for a custom domain on a Heroku app. Examples include herokuapp.com
, herokudns.com
, and .herokuspace.com
. Which one should you use?
Resolution
All Heroku applications are browsable via the your_app_name.herokuapp.com
address, however, to use Custom Domains, you will need to setup your DNS to use the correct CNAME
targets, which differ depending on how your application is setup.
If your application is in a Private Space:
You can check the correct CNAME
target private space apps by running the Heroku CLI command: heroku domains -a your_app_name
and by checking Domains and certificates" settings in Dashboard.
The DNS target will be of the format <app-haiku-nr>.<space-haiku-nr>.herokuspace.com
.
If your application uses Heroku SSL (SNI) or Automated Certificate Management:
Your CNAME
targets will use our herokudns.com
address. Each custom domain will be assigned it's own address. The exact CNAME
target is randonly generated but will be in the format <random-haiku-string>.herokudns.com
. You should add DNS CNAME
records for each of your custom domains to point to the corresponding herokudns.com
target.
You can check the correct CNAME
target for Heroku SSL (SNI) by running the Heroku CLI command: heroku domains -a your_app_name
.
You might have old Custom Domains that still display a your_app_name.herokuapp.com
CNAME
target. You should remove, and re-add these to ensure a herokudns.com
CNAME
is set up.
Please note: herokudns.com
addresses are not browsable, they will not display your application, as they are only intended to host your SSL certificate.
Full information is available on our Dev Center: Heroku SSL and Automated Certificate Management
If your application is only accessed via HTTP and does not use any SSL:
You can check the correct CNAME
target for Custom Domains by running the Heroku CLI command: heroku domains -a your_app_name
.
- Custom Domains created before
herokudns.com
was available will displayyour_app_name.herokuapp.com
as the DNSCNAME
target. - Custom Domains recently created will display
your_custom_domain.herokudns.com
as the DNSCNAME
target.
You should setup your DNS CNAME
targets based on these settings, although using your_app_name.herokuapp.com
will work for both OLD and NEW Custom Domains. If the <random-haiku-string>.herokudns.com
is available for the Custom Domain, then you should use this as it will make transitioning to Heroku SSL easier in the future.
Please note: herokudns.com
addresses are not browsable, they will not display your application, as they are only intended to serve as a CNAME
target.
How to test your DNS is setup correctly:
DNS changes take time to propagate, usually this happens within a few minutes to an hour, but this can longer depending on your DNS provider. You can check your DNS by using online tools such as http://zone.vision, or using the command line tools dig
and host