Locked lesson.
About this lesson
Once your website project is done, you'll probably want to use your own domain name. In this lesson, we'll discuss how to add a domain name to your new project.
Exercise files
Download this lesson’s related exercise files.
39 - Add Domain Name.docx57.5 KB Add Domain Name - Solution.docx
56.1 KB
Quick reference
Add Domain Name
You can easily use your own custom domain name with your Heroku app.
When to use
Do this whenever you want to use a domain name for your app.
Instructions
Adding a domain name is a two step process.
- Add it to Heroku.
- Point your Domain name to Heroku at your registrar (where you bought the domain).
To add your domain name to heroku, log into your heroku account at Heroku.com and click on your app. Then click on Settings, then click on Add Domain. Type your domain name in (www.yourdomain.com) and click save.
Next, log into your registrar and go to advanced DNS setttings. Add a CNAME. For host, enter www, and then enter the URL of your Heroku app.
Hints & tips
- Add Domain name to Heroku
- Add CNAME to your registrar
- 00:03 Okay, so we've got our app, it's live on Heroku.
- 00:06 But we've got this kind of weird domain name, djangoresume2.herokuapp.com, and
- 00:11 that's fine, this is the free tier.
- 00:13 And that's okay if that's all you want, but
- 00:14 if you want your own domain name, how do you do that?
- 00:15 Well, it's actually pretty easy and that's what we're going to do in this video.
- 00:21 So, this is basically a two-step process,
- 00:23 we need to tell Heroku that we want to use a domain name.
- 00:26 And then we need to actually point our domain name from our registrar to Heroku.
- 00:32 Now, if you're not familiar with domain names, you buy them from a registrar,
- 00:36 they're usually about $10 a year.
- 00:38 You have to renew them every year, and the place you buy them from is a registrar,
- 00:42 and there are a bunch of those, I mean, hundreds of them.
- 00:45 You may have heard of GoDaddy, that's a registrar where you register domain names.
- 00:49 I use something called Namecheap, it's really cheap, it's probably one of
- 00:53 the cheapest ones out there, but they're a really, really good company.
- 00:57 Google has their own registrar, Google Domains, so it really doesn't matter which
- 01:02 registrar you use, but they're all going to be slightly different.
- 01:06 So I'm going to show you how to do it on Namecheap.
- 01:08 If you use somebody else, you're going to have to just google something
- 01:11 like GoDaddy, or Heroku domains, or something like that.
- 01:15 You'll see a little tutorial more than likely, and it'll show you how to do it.
- 01:18 But I'll show you how to do it on mine, and
- 01:20 you should be able to figure out how to do it on yours just from that.
- 01:23 So the first thing we need to do is head over to Heroku, and login to your account,
- 01:27 now I'm already logged in.
- 01:29 So it lists all the apps, I have three pages of apps.
- 01:32 What you want to do is just you probably only have one app, but
- 01:35 find it wherever it is.
- 01:36 Here it is right here, djangoresume2, and just click on it, and
- 01:40 then go over to Settings.
- 01:41 And if you scroll down, you'll see domains, so
- 01:44 we just need to add whatever our domain name is.
- 01:48 So mine is www.elderresume.com,
- 01:52 type in www., whatever your domain is.
- 01:56 It could be .net, .org, dot whatever,
- 01:59 whatever you've purchased from your registrar.
- 02:02 So we'll then go ahead and click Next, and that's all there is to it on Heroku Zand.
- 02:07 So now you have to tell your registrar to point that domain name towards Heroku.
- 02:12 So to do that, log into your registrar and I'm at Namecheap here, and
- 02:16 then just scroll down until you find your domain name.
- 02:19 Here it is elderresume, and I'm going to click on Manage, and
- 02:24 what we want is Advanced DNS.
- 02:26 And inside of here, what we want to do is add a new record.
- 02:30 So I'm going to click add a new record, and
- 02:32 the type of record we want is something called a CNAME.
- 02:36 So when we do that it pops up here.
- 02:38 For host, we want www, and for the target, we want whatever URL, our Heroku app is.
- 02:45 Now mine happens to be djangoresume2.herokuapp.com,
- 02:48 yours will be something different, because we can't have the same names.
- 02:53 If you didn't change the name of it, it's going to be whatever weird word Django
- 02:57 just created for you randomly, and probably a bunch of weird numbers.
- 03:02 So like willowycreek59876.herokuapp.com or whatever.
- 03:08 So just copy that whole thing, and just that, not the HTTPS stuff.
- 03:13 So I'm going to copy this head back over here and
- 03:16 I'm just going to paste it in, all right?
- 03:19 And for TTL, that stands for time to live, it just means how often are we going to
- 03:24 check to make sure this domain name has been updated.
- 03:27 I'm just going to put it at one minute, and then click Save Changes.
- 03:30 Now, like I said, your registrar very likely will look very different than this,
- 03:35 but you're doing the same thing on your registrar.
- 03:37 You're adding a CNAME, the host should be www, the value will be your URL.
- 03:43 And you can put this as one minute if you want or automatic, it just means how fast
- 03:47 it will update, I want it to update right away, so that's all there is to it.
- 03:52 Now, for this to take effect, it's going to take at least one minute, and
- 03:56 then after that it can take up to hours.
- 03:58 Because there are name servers all over the world, and
- 04:02 they all have to be updated, and they update on their own timeframe.
- 04:05 So they tell you it should be updated within 12 hours, for me,
- 04:10 it's usually like a half an hour or less.
- 04:12 One thing you can do to speed it up is to flush your DNS cache on your
- 04:16 local computer.
- 04:17 And that means your computer has a cache of the DNS server database on your
- 04:22 computer, you want to update that right away.
- 04:25 And to do that, just go to your Windows Start menu and type in CMD, and
- 04:28 you're going to get the command prompt.
- 04:30 And you can just type in ipconfig /flushdns, and
- 04:35 this will just flush out your DNS cache, and you can exit.
- 04:41 So now, if some time goes by, or if you want to check it right away,
- 04:46 just type in www.elderresume, or whatever your domain name is.
- 04:52 As you can see, it can't find it yet because it hasn't updated yet.
- 04:55 But usually probably within a half an hour, I just hit Reload and it worked.
- 04:59 So I clicked Shift, I held down the Shift key, and
- 05:03 I clicked Reload, that forces a reload.
- 05:06 And when I did that, boom, it works, so it works, our domain name is live.
- 05:10 And just that easy, and like I said,
- 05:12 domain names cost like 10 bucks, they're not very expensive, so that's pretty cool.
- 05:16 So that's all for this video, in the next video,
- 05:20 we'll do a little bit of review, we'll recap some stuff, and go from there.
Lesson notes are only available for subscribers.