跳到正文
域名与 DNS · 5 分钟

How to connect a domain to a VPS: A record, www and dig check

To connect a domain to a VPS, create an A record for the bare domain (@) pointing to the server's IPv4 address, and a CNAME record for www pointing to the domain itself. Make the change in the DNS panel of whoever serves your domain's nameservers, then check it with dig: depending on the TTL, the new address shows up within minutes to a few hours.

What you need

  • A server with an IP address. Every VPS comes with a dedicated IPv4 address; it's shown on the server's page in your account. For a website or landing page, Pulse (2 vCPU, 2 GB RAM, 15 GB NVMe, $10/month) is enough. Not sure? See how to choose a plan.
  • A domain. If you don't have one yet, you can register a .com on the domains page. Prices are yearly, we register the domain manually after your request, usually within one business day, and you pay the invoice in crypto (how to pay). A domain registered elsewhere works just as well: you don't need to move it to point it at your server.
  • Access to the DNS panel. Records are edited where the domain's nameservers point: the registrar's DNS or a separate DNS service.

1. Find out who serves your DNS

dig +short NS example.com

The answer is the list of nameservers. Edit records in the panel of the provider they belong to. Changes made anywhere else, for example at the registrar while the nameservers point to another service, have no effect.

If dig is missing on Ubuntu 24.04 or Debian 12, install it:

apt install -y dnsutils

2. Create the A record

In the DNS panel add a record: type A, name @ (the bare domain), value is your server's IP, TTL 300 while you set things up. Delete any old A records for @, such as a registrar's parking page: with two A records, visitors land on either address at random.

Only add an AAAA record if you've confirmed your server has an IPv6 address. If the zone has an old AAAA record from previous hosting, delete it: devices with IPv6 prefer it and will keep opening the old site.

3. Point www with a CNAME

Add a record: type CNAME, name www, value example.com. In zone-file form the result looks like this:

example.com.      300  IN  A      203.0.113.10
www.example.com.  300  IN  CNAME  example.com.

A CNAME can't be used on the bare domain itself, so @ always gets an A record.

4. Choose the TTL

TTL is how many seconds resolvers may cache the answer. While you're setting up or moving to a new server, use 300. Once everything works, raise it to 3600 or more. Keep in mind that if the old record had a TTL of 86400, some resolvers can serve the old address for up to a day after the change. Lower the TTL a day before a planned move.

5. Check with dig

dig +short example.com A
dig +short www.example.com
dig @1.1.1.1 +short example.com A
dig @8.8.8.8 +short example.com A

All commands should return your server's IP (for www, the CNAME first, then the IP). On Windows use nslookup example.com 1.1.1.1.

6. Wait for propagation

There's no single switch: each resolver keeps the old answer until its TTL runs out. For a freshly registered domain or new nameservers, delegation in the .com zone can take up to 24–48 hours. dig +trace example.com shows the whole chain from the root servers and where the old data still sits.

Once the domain resolves, set up the website and HTTPS: Nginx and a free Let's Encrypt certificate.

Common mistakes

  • Name field contains the full domain. Many panels append the zone automatically, so example.com in the name field becomes example.com.example.com. Use @ and www.
  • Your computer still sees the old IP. That's the local cache. Check with dig @1.1.1.1; on Linux clear the cache with resolvectl flush-caches.

Order Pulse

How to connect a domain to a VPS: A record, www and dig check · dedisrv