109

I am trying to get a domain name I bought through GoDaddy to work with my Heroku hosted site.

How do I configure my domain name to work with Heroku?

Boann
  • 44,932
  • 13
  • 106
  • 138
allegutta
  • 5,487
  • 8
  • 35
  • 51
  • 21
    I don't agree that the question is too broad. I find it quite specific. Setting up a ruby on rails app with heroku and create a GoDaddy domain that points to it. I had the exact same problem and the answer here provided gave me the solution I was looking for. – Hector Ordonez Feb 03 '16 at 10:54

4 Answers4

302

[Updated 31.10.2014] Allright! It works! Here is how I did it from scratch, so others with the same problem can fix it too. First I will explain how to setup Heroku and GoDaddy, then I will explain how to create a naked domain (www.example.com -> example.com).

Setup Heroku and GoDaddy:

  1. In your project folder in terminal (on your computer) write heroku domains:add www.example.com (where www.example.com is the domain you have bought at GoDaddy)

  2. Sign in to GoDaddy -> DOMAINS -> choose your domain -> Launch (this will take you to the Domain Details)

  3. Click 'DNS Zone File' tab

  4. Remove the CNAME record named 'www' (which points to @)

  5. Click 'Add record' -> CNAME(Alias) -> 'Host' should be www and 'Points to' should be your Heroku address (example supermoo-bil-3411.herokuapp.com). TTL can be 1 hour.

It can take some time for the DNS to propogate. For me it took about 10 minutes.

That's it! supermoo-bil-3411.herokuapp.com will now be under www.example.com :)

Create a naked domain:

A naked domain removes the need to write www in front of your domain name. This can be done by forwarding example.com to www.example.com. This is super easy on GoDaddy:

  1. In the same window as above, click on the 'Settings' tab

  2. Under Forwarding -> Domain -> Click 'Manage' -> then click 'Add Forwarding'

  3. 'Forward to' should be www.example.com (your domain), 'Redirect type' should be '301 (Permanent)', 'Forward settings' should be 'Forward only'

  4. Make sure "Update my nameservers and DNS settings to support this change. (Recommended)" is checked

    That's it! You are done :)

Useful links:

Thanks to Ryan Kazinec for help :)

allegutta
  • 5,487
  • 8
  • 35
  • 51
  • When I try adding the domain (heroku domains:add www.example.com) I get: No account specified.Run this command with --account Do you know what is this account? – misschoksondik Jul 05 '14 at 21:39
  • What should the cname record become if you install an ssl cert via herokus addons? – Chris Hawkins Jul 07 '14 at 21:03
  • 2
    I think it is important to note that if you remove ALL records, as you suggest in step 4, that if you have email, google apps, or other services set up, you can really mess things up. The only records that need to be edited to make this work are the A record and the CNAME records for www and any subdomains included. – biggles Jul 30 '14 at 22:30
  • @allegutta did you implement SSL on your site. If so, does the alias just point to the herokussl url? – Moosa Nov 05 '14 at 19:49
  • @Moosa Hi, I haven't done that yet. If you do, let me know how you solved it. – allegutta Nov 08 '14 at 20:08
  • 1
    It's just CNAME not CNAME(Alias) – jack blank Apr 22 '16 at 22:34
  • @jackblank So in the GoDaddy setup, it only stands CNAME now? – allegutta Apr 22 '16 at 22:36
  • i was missing removing default cname with www – ImranNaqvi Jul 20 '16 at 11:24
  • This answer is great! - make sure on terminal run `host www.example.com` – medev21 Nov 10 '16 at 19:28
  • I've done all this, but I don't know how to change the 'DNS Target', which was provided by my Heroku CLI: `*domain*.com.herokudns.com` - I tried inputting this into the NS (Nameservers) section, but I guess this is not right... (the one where it has two servers, `ns17.domaincontrol.com` and `ns18.domaincontrol.com`). – Paulos3000 Jan 28 '17 at 17:02
  • One of my CNAME records looks like this CNAME www @ 1 Hour I am trying to add another one as you mentioned CNAME www www.zup.chat.herokudns.com and it keeps throwing this error The specified CNAME already exists in the zone. any ideas – PirateApp Mar 07 '17 at 12:17
  • @PirateApp you can edit the already existing CNAME record and instead of @ you can write 'www.zup.chat.herokudns.com'. You don't need to add a new one. – Ajay Bhasy Apr 09 '17 at 08:28
  • I just followed this and it took less than 60 seconds to work.... super quick – loxyboi Jun 30 '17 at 10:16
  • Superb! Same speedy results as loxyboi – Manuel Hernandez Aug 19 '17 at 13:05
  • I have tried but it is not working for naked domain – TheVinspro Jul 23 '20 at 09:55
1

DNS settings tend to have a lag time.

Have you attempted to access the app from another device? (Say a smart phone that is operating on another network?) I've seen on several occasions where my local dns cache was causing issues which is why accessing it from another device may shine some light on your situation.

If you're making the dns changes from a windows based pc you can flush your dns cache which can sometimes resolve your issue.

1.) Right Click on CMD.exe (aka command prompt) 2.) Click on Run as Administrator. 3.) type: ipconfig /flushdns 4.) Press Enter key

But bear in mind dns changes can take a while to propagate.

  • Hi, it has been three days since I did the DNS setup, and I have tried to load the site on different devices and machines. How long does it usually take? – allegutta Jan 02 '13 at 16:40
  • 1
    There's a field called TTL in your DNS record. This tells other DNS servers how long (in seconds) to cache a DNS entry. Set this to a low value while you're testing and then crank it up once you have your DNS figured out. Some DNS servers may override the TTL with their own value, so beware, but I think at worst this is usually a couple of hours. – Adam Fabicki Jan 02 '13 at 17:43
  • Usually a couple of hours at most but I've seen warnings that it can take up to 24 hours to propagate. Nonetheless three days should be plenty of time. – Ryan Kazinec Jan 02 '13 at 18:02
  • Here is a more detailed tutorial compared to the one you mentioned in your question: https://devcenter.heroku.com/articles/custom-domains – Ryan Kazinec Jan 02 '13 at 18:04
  • Thanks Ryan. I did all the steps in this tutorial too :) It should work but, it doesn't.. Do I need to change the `A(Host)` IP adress at GoDaddy, or is `CNAME(Alias)` the only thing I should change? – allegutta Jan 02 '13 at 18:31
  • No problem. Okay, I found the following screen casts that may shed some light on this. After watching the first video (without email support) it was mentioned that first all of the cname records need to be removed first, then you add the two additional entries. Before you do this I would save a screen shot of all of the entries you currently have so they can be restored if something goes wrong. Also, these videos are a few years old. I don't use heroku so I can't confirm they're still accurate. http://blog.heroku.com/archives/2009/10/7/heroku_casts_setting_up_custom_domains/ – Ryan Kazinec Jan 02 '13 at 18:46
  • 1
    Thanks for the link Ryan, it really helped me solve this! – allegutta Jan 03 '13 at 16:49
0

Go to https://dnsimple.com/r/ecc41c23013629 and open an account.

They have a one click set up for heroku and you can set the TTL to as low as one minute. Then on the GoDaddy side just change the dns servers from the go daddy servers to the dnsimple ones(all explained on the dnsimple site). SIMPLE ;)

Your domain is still hosted by GoDaddy

GoDaddy is not the place to be managing you dns in my humble opinion.

Paul Williams
  • 3,591
  • 1
  • 11
  • 6
0

One of the easiest ways to setup an external domain with Heroku is using this addon: https://addons.heroku.com/zerigo_dns - You simply have to point the dns nameservers to

a.ns.zerigo.net
b.ns.zerigo.net
c.ns.zerigo.net
d.ns.zerigo.net
e.ns.zerigo.net

I am not affiliated with Zerigo DNS - just a happy user. Any yeah it's free for 50,000 queries per month and for $20/month you get unlimited queries.

Hope this helps.

Paul
  • 1,139
  • 3
  • 12
  • 23