I've followed all the instructions on https://devcenter.heroku.com/articles/custom-domains to get my custom domain set up, and it still isn't working.
On Heroku, I have the following domains:
myapp.herokuapp.com
myapp.com
www.myapp.com
And on Namecheap, I have the following settings:
HOST NAME | IP ADDRESS/URL | RECORD TYPE
@ http://myapp.com URL Redirect
www myapp.herokuapp.com. CNAME(Alias)
When I run: "host www.myapp.com" in my terminal, I expect to get "www.myapp.com is an alias for myapp.herokuapp.com". Instead, I get:
"www.myapp.com is an alias for myapp.heroku.com"
I can't figure out why it is pointing to myapp.heroku.com, because I have only specified myapp.herokuapps.com.
Does anybody know why this is happening?
First connect to the Heroku dashboard, select the heroku application and go to the "Settings" tab. Scroll down until you reach the Domain and certificates section. Click on the purple "Add domain" button and type the domain name with its subdomainyou want to use.
It is also possible to make your app accessible via a custom domain that is registered with Namecheap. Here you can add custom domains to both free and paid Heroku accounts. Domains can be inspected and managed using either Heroku CLI or Dashboard.
You can buy a custom domain name with a domain registration service. Add the custom domain to your app with the heroku domains:add command. Look up the Heroku-supplied DNS target for the custom domain using the heroku domains command.
Go to the record editor and two DNS records, one for each host name, pointing to the Heroku SSL endpoint: Add an ALIAS record to point example.com to Heroku. Leave the Name of the record empty and set the Content field to the SSL endpoint example.com.herokudns.com. Add a CNAME record to point www.example.com to Heroku.
Update note: Heroku and Namecheap change they interfaces every so often. This answer may have outdated screenshots, but it will be updated over time. See these updates below.
I've just done this myself so I thought I'd chime in as the answer doesn't illustrate how to get both www.domain.com and domain.com working. Heroku also changed its admin interface abit.
- Set both record types to CNAME (Alias) and enter your <name>.herokuapp.com
in both url-boxes (@ and www).
(PS: If they're not there, click the "Add new record" and add them there.)
domain.com
and click Save.www.domain.com
and click Save.That's it, You're done! Now when you enter domain.com
or www.domain.com
in your browser, both will show your Heroku project.
In this example, http://lakka.herokuapp.com would be accessible (after DNSes update) also on http://lakkatracker.com and http://www.lakkatracker.com.
(If you want to redirect traffic from www.domain.com to domain.com, which is a good practise, you can use the record type "URL (Redirect)" for the www host name)
It can take some time before your DNSs recognize the changes. You can try using a proxy for testing, like Anonymouse, if your changes aren't reflected immediately.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With