Point a domain at your server (A record)
A domain points at a server through a DNS A record that maps the name to the server's IPv4 address.
- Updated Nov 27, 2026
- Markdown
Point your domain at your server with an A record and check it with dig.
- A domain you control, with access to its DNS settings
- Your server's public IPv4 address
To point a domain at your server, create an A record that maps the name to the server’s public IPv4 address, then check it with dig +short example.com A. Most changes show up within minutes, but resolvers may keep the old answer until its TTL runs out.
How it works#
DNS is a distributed phone book. Your domain has a zone, which is a list of records, and the zone is served by name servers that you choose at your registrar. When a browser wants example.com, it asks a resolver (usually your ISP’s or a public one such as 1.1.1.1). The resolver walks down from the root to your name servers, gets the answer, and remembers it for the record’s TTL (time to live, in seconds). Until the TTL runs out, the resolver answers from memory and never asks you again.
An A record maps a name to an IPv4 address. A name can have several A records, and each name is separate: example.com and www.example.com are two names, so each needs its own record (or a CNAME for www). In most dashboards the bare domain is written as @.
Visitors on IPv6 networks look for an AAAA record first. If one exists, they use it. If you have none, they fall back to IPv4. That is why a wrong AAAA record hurts and a missing one does not.
Step 1: Find your server’s public address#
On the server:
curl -4 https://ifconfig.me-4 forces IPv4. What you should see: one IPv4 address, for example 203.0.113.10. If your provider gives you an address in its dashboard, use that one instead. For a server behind NAT at home, this shows your router’s address, and you also need port forwarding.
Step 2: Add the A records#
In your DNS provider’s dashboard add:
| Type | Name | Value |
|---|---|---|
| A | @ (the bare domain) | 203.0.113.10 |
| A | www | 203.0.113.10 |
Leave the TTL at the default or set it to 300 seconds while you test. A short TTL means a wrong value is corrected quickly. Remove any old or parking-page records for the same names, because two A records with different values make visitors reach either one.
Step 3: Query the answer#
dig +short example.com AWhat you should see: 203.0.113.10, your server’s IP, and nothing else. +short prints only the answer. If you see nothing or an old address, wait and try again, or ask a public resolver directly:
dig +short example.com A @1.1.1.1@1.1.1.1 sends the query to that resolver instead of your own. If dig is missing, install dnsutils on Debian or Ubuntu.
Check it worked#
Check both names and then the server itself:
dig +short www.example.com A
curl -I http://example.comWhat you should see: the same IP from dig for both names, and a response from your web server (any HTTP status line, such as HTTP/1.1 200 OK, means the name reached a live server). If curl hangs, the DNS is fine but the server’s firewall or web server is the problem.
Edge cases and gotchas#
- Cached answers hide your change. Resolvers keep the old value until the previous TTL ends, not the new one. Lower the TTL before a planned move, wait for the old TTL to pass, then change the record.
- The bare domain and
wwware separate. Fixing one does not fix the other. Add both. - A CNAME cannot sit next to other records at the bare domain. Use A records there. Some DNS hosts offer ALIAS, ANAME or CNAME flattening if you need to point the bare domain at another hostname.
- A proxy in the way. If your DNS host proxies traffic (an orange cloud, for example), dig shows the proxy’s address, not yours. That is expected. It also changes how HTTPS and redirects behave.
- Wrong or stale AAAA. If you added an AAAA once and later moved servers, IPv6 visitors keep going to the old host. Update or remove it.
- Trailing dots and the name field. Many dashboards append the domain automatically. Typing
example.comin the Name field can createexample.com.example.com. Use@for the bare domain. - Your own machine caches too. If dig is right but the browser is wrong, the browser or the operating system cached the old answer. Restart the browser or flush the OS DNS cache.
Troubleshooting#
| Symptom | Likely cause | Fix |
|---|---|---|
| dig prints nothing | Record not created, or wrong zone | Check the record exists in the DNS provider that your name servers point to |
status: NXDOMAIN in dig example.com | The name does not exist in that zone | Add the record, check spelling |
| Old address returned | Cached until TTL ends | Wait, or query @1.1.1.1 and the authoritative name server |
| Works for www only | No record for @ | Add the A record for @ |
| Address is not yours | DNS proxying is on | Turn proxying off for the test, or expect the proxy’s IP |
Browser says This site can't be reached but dig is right | Server firewall closed or web server down | Check ports 80 and 443 and the service |
curl hangs after correct dig | Firewall blocks port 80 | Allow it in the firewall and the provider’s security group |
Name shows example.com.example.com | The dashboard appended the domain to what you typed | Use @ for the bare domain and www for www |
| Two different addresses come back | An old record is still in the zone | Delete the extra A record |
Real-world scenario#
Ana buys example.com and gets a VPS with the address 203.0.113.10. She opens her DNS dashboard, deletes the registrar’s parking record, and adds two A records: @ and www, both pointing at the server. She sets the TTL to 300 seconds because she expects to fix typos.
dig +short example.com A
dig +short www.example.com A @1.1.1.1
curl -I http://example.comThe first answer is still the parking page address. Her own resolver cached it. The query to 1.1.1.1 already shows 203.0.113.10, so she knows the zone is right and waits. Ten minutes later the first command agrees. The curl call hangs, which is not DNS: her cloud firewall blocks port 80. She opens ports 80 and 443 (see set up a firewall with UFW and the provider’s own firewall) and curl returns the default page. The next steps are in HTTPS and Let’s Encrypt and check DNS with dig.
Quick reference#
| Task | Command or setting |
|---|---|
| Bare domain | A record, name @ |
| www | A record, or CNAME to the bare domain |
| Ask your resolver | dig +short example.com A |
| Ask a public resolver | dig +short example.com A @1.1.1.1 |
| Check IPv6 | dig +short example.com AAAA |
| Test the server answers | curl -I http://example.com |
| While testing | TTL 300 seconds |
Related lessons#
- DNS record types explained: what A, AAAA and CNAME do
- Check DNS with dig: read dig output properly
- DNS propagation and TTL: why changes seem slow
- What is a VPS: where the server address comes from
Next#
Understand every record you might add next in DNS record types explained.
Try it: Check your A record
After adding the A records at your DNS provider, verify them with dig.
Want a real machine? Free browser labs: Killercoda
Check what you learned
Frequently asked questions
How long does a DNS change take?
Often a few minutes, but the record's TTL decides how long old answers are cached. It can take longer for resolvers that cached the old value.
Do I need an AAAA record too?
Only if your server has a public IPv6 address and listens on it. An A record is enough for IPv4.
Why does the site work on my phone but not on my laptop?
The two may be using different resolvers with different cached answers. Ask a public resolver with dig and compare, then wait for the TTL to run out or flush the local cache.
Should I add an AAAA record if I am not sure about IPv6?
No. A wrong AAAA record sends IPv6 visitors to a server that does not answer. Add it only after you confirm the server listens on that IPv6 address.
Keep going: guides and tutorials
- Self-Hosted Static Site Hosting: Deploy a Folder With Levelrail Self-hosted static site hosting from a plain folder: one deploy command, _redirects, _headers and a custom 404 honored, plus a one command rollback.
- Deploy Next.js on a VPS With Docker, Git Push and HTTPS Deploy a Next.js app to your own VPS with Docker, a health check, HTTPS and rollback. Includes the NEXT_PUBLIC build trap that leaves variables empty.