You’ve bought a domain and a VPS. Now example.com needs to lead to your server. That happens in DNS: you create records that map your domain name to the server’s IP address. It takes a few minutes to set up, then up to a few hours (usually less) to take effect everywhere.

1. Find your server’s IP address

It’s shown in your VPS client area, or on the server:

curl -4 ifconfig.me

See VPS IP addresses.

2. Decide where DNS is managed

DNS records live at whichever provider your domain’s nameservers point to:

  • your domain registrar (the default after buying a domain);
  • a DNS provider such as Cloudflare (you changed the nameservers there);
  • rarely, your own DNS server.

Check:

dig +short NS example.com

Make changes at that provider. Editing records at the registrar does nothing if the nameservers point to Cloudflare.

3. Create the records

Type Name / Host Value Purpose
A @ (the bare domain) 203.0.113.10 example.com → your server
A or CNAME www 203.0.113.10 or example.com www.example.com → same server
AAAA @, www IPv6 address Only if your server has IPv6 configured
A app, blog… 203.0.113.10 Subdomains (optional)
  • @ means the domain itself. Some providers want the field empty, or the full domain name.
  • Don’t create an AAAA record unless the server really serves the site over IPv6. A wrong AAAA record breaks the site for IPv6 users.
  • Delete old parking-page records (A records pointing to the registrar’s servers).

See DNS records explained and Nginx subdomains.

4. TTL and propagation

TTL (time to live) is how long resolvers cache a record. When changing an existing record, lower the TTL (for example to 300 seconds) a day in advance, so the switch is fast. New records usually work within minutes. Changed records take up to the old TTL to update everywhere.

dig +short example.com              # your resolver
dig +short example.com @1.1.1.1     # Cloudflare's resolver
dig +short example.com @8.8.8.8     # Google's resolver

See DNS propagation.

5. Configure the web server for the domain

DNS only brings visitors to the IP. The server must know the domain:

6. Don’t break email

If you use email on this domain (Google Workspace, Microsoft 365, or another provider), keep the MX, SPF (TXT), DKIM and DMARC records they gave you. Changing the A record doesn’t affect email, but switching nameservers to a new DNS provider means copying all records first. See email for your domain and SPF, DKIM and DMARC.

Using Cloudflare

With Cloudflare as the DNS provider, records can be proxied (orange cloud: traffic goes through Cloudflare’s CDN) or DNS only (grey cloud). For the first HTTPS setup on your server, DNS-only is simplest. Then enable the proxy, with SSL mode “Full (strict)”. See using Cloudflare with a VPS.

Verify

dig +short example.com A
curl -I http://example.com
ping -c2 example.com

The A record should return your server’s IP, and curl should get a response from your web server.

Troubleshooting

Problem Check
Old IP still returned TTL not expired; check other resolvers; flush local DNS cache
Changes have no effect Records edited at the wrong provider (check NS)
“This site can’t be reached” Web server not running, or firewall blocking 80/443
Wrong site shown Server block server_name missing; default server catching it
Certbot fails DNS not pointing here yet, or an AAAA record pointing elsewhere

Quick reference

Task Record / command
Bare domain A @ → server IP
www A www → IP or CNAME www → example.com
Check nameservers dig +short NS example.com
Check record dig +short example.com @1.1.1.1
Before changes Lower TTL to 300 s

Related: what is a VPS and move a website to a VPS.

  • DNS
  • Domains
  • VPS Guide