How to point a domain or subdomain to your server
A, AAAA and CNAME records explained in plain words, with how to check that your name points where it should.
· 2 min read
You bought a server or set up hosting, and now you want people to reach it by a name instead of a string of numbers. That link between a name and a server is a DNS record. Here is what the common ones do and how to pick the right one.
The three records you need to know
- A record: points a name to an IPv4 address, such as
203.0.113.10. Use it when your host gives you an IP address, which is the usual case for a VPS. - AAAA record: the same thing for an IPv6 address, such as
2001:db8::10. Add one if your server has an IPv6 address; visitors on IPv6 networks will use it. - CNAME record: points a name to another name, such as
my-site.vercel.app. Use it when a hosting platform tells you to, because their IP addresses can change while the name stays the same.
A name can't have a CNAME and other records at the same time. That is why the bare domain (example.com, called the apex) usually can't be a CNAME: it already has records the domain needs to work. Some DNS providers offer a workaround called ALIAS or CNAME flattening. For a subdomain like app.example.com a CNAME is fine.
Which one should I use?
- Your host gave you an IP address: use an A record (and an AAAA record if you also got an IPv6 address).
- Your host gave you a host name like
something.netlify.app: use a CNAME record. - You are not sure: ask your host which records they want. Their setup page usually says it word for word.
What TTL means
Every record has a TTL (time to live), in seconds. It tells other DNS servers how long they may remember the answer. A TTL of 3600 means an hour. When you are about to move a site to a new server, lower the TTL a day before, so the change reaches everyone faster. Raise it again afterwards.
Check that it works
DNS changes usually show up within minutes, but can take as long as the old TTL. You can ask DNS directly from a terminal:
dig +short app.example.com
nslookup app.example.com
Both print the address the name points to. If you see the right IP, the record is live. If your browser still shows the old site, it may have cached the old answer; try a private window.
Don't forget HTTPS
A DNS record only sends visitors to your server. The padlock comes from a certificate on the server itself. We wrote a separate guide on getting free HTTPS with Caddy or Certbot.
A free name for your portfolio
If you have a server but no domain yet, you can get a free name like you.softwaretrinkets.com pointed at it. We check every request and add the record for you. Get a free subdomain.