Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting up a custom domain with heroku and namecheap

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?

like image 710
mravca Avatar asked Oct 16 '13 09:10

mravca


People also ask

How use Namecheap domain with Heroku?

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.

Does namecheap work with Heroku?

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.

Does Heroku allow custom domain?

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.

How do I redirect my domain to Heroku?

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.


1 Answers

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.

Namecheap


  • First, login to Namecheap.
  • Go to Domain List and click "Manage" for the domain you're configuring.

Namecheap - 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.)

enter image description here

Next, head over to Heroku


  • Login and choose your project from the list. For this example, we're choosing the "Lakka" project.

enter image description here

  • On the project page, click Settings

enter image description here

  • Scroll down and find the Add domain section

enter image description here

  • Enter your domain.com and click Save.
  • Click the button again, and input your www.domain.com and click Save.

enter image description here

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.

like image 124
Coreus Avatar answered Sep 21 '22 08:09

Coreus