Domains & DNS
Your app answers at 203.0.113.10 - a number nobody will type or trust. A domain turns that number
into yourproject.com. The system that maps the name to the number is DNS; if the underlying
"names → addresses" machinery is new to you, IP, DNS & Ports explains it from
the ground up. Here's the practical sequence to point a fresh domain at your box.
Buy one, then choose who runs its DNS
Buy a domain from any registrar. Cheap and fine for a side project; pick the name, pay, done.
Then decide who answers DNS queries for it. Two options:
- Use the registrar's DNS - add records right there. Simple.
- Point the registrar's nameservers at another DNS provider (very commonly Cloudflare, which is the next phase). You change the nameservers at the registrar to the two the provider gives you; from then on, you manage records at the provider.
$ dig +short NS yourproject.com
amara.ns.cloudflare.com.
rob.ns.cloudflare.com.
What just happened: dig asked which nameservers are authoritative for the domain - here, Cloudflare's.
⚠️ Nameserver changes can take a while to propagate (minutes to a day). If your records "aren't working,"
confirm the nameservers switched first - nothing else matters until they have.
The two records you need: A and CNAME
- A record maps a name straight to an IP address. Point the apex at your box:
yourproject.com → 203.0.113.10. - CNAME maps a name to another name (an alias). Point
wwwat the apex:www.yourproject.com → yourproject.com.
Type Name Value
A yourproject.com 203.0.113.10
CNAME www yourproject.com
⚠️ Apex vs www - the apex usually can't be a CNAME
This trips up nearly everyone. The apex (also "root" or "naked" domain - yourproject.com with no
subdomain) cannot, by the DNS spec, be a CNAME. Only an A record (or AAAA for IPv6) works at the
apex. So:
- apex (
yourproject.com) → A record → your IP. - www (
www.yourproject.com) → CNAME → the apex.
⚠️ Many DNS providers (Cloudflare included) offer CNAME flattening that lets you put a CNAME-like
record at the apex by resolving it to an IP behind the scenes - handy, but if your provider doesn't,
remember: apex = A record. Decide which one is canonical (most pick the apex, redirecting www → it,
or vice versa) and be consistent, so links and cookies don't split across two hostnames.
⚠️ .dev (and .app) are HTTPS-only
If you bought a .dev domain because it's cute - know this before you lose an hour: .dev and .app
are on the browser HSTS preload list, which means browsers refuse to load them over plain http:// at
all. There's no "I'll add HTTPS later" with a .dev; until HTTPS works, the site simply won't open -
not a warning, a hard fail. That's fine, because HTTPS is the very next phase - just don't panic when
http://yourproject.dev looks dead. (On a .com you'd see it over http first; on .dev you won't.)
Recap
- Buy a domain, then either use the registrar's DNS or point its nameservers at a DNS provider
(often Cloudflare - next phase). Confirm the nameserver switch with
dig NSbefore debugging anything else. - A record → name to IP (use it for the apex). CNAME → name to name (use it for www).
- ⚠️ The apex can't be a CNAME - it needs an A record (unless your provider does CNAME flattening).
- ⚠️
.dev/.appwon't load over HTTP at all - they're HTTPS-only, so the site looks broken until the next phase is done.
The name resolves to your box. Now make it HTTPS, safe, and fast - with Cloudflare.
← Phase 3: Docker & Your Private Repo · Guide overview · Phase 5: Behind Cloudflare →
Before the quiz: without looking back, say (or jot down) the core idea of this phase in your own words.
Check your understanding 3 questions
1. What is the difference between an A record and a CNAME?
2. Why can't the apex (naked) domain usually be a CNAME?
3. Why do `.dev` and `.app` domains look broken until HTTPS works?