Mastodon

How to Point a Domain to Your VPS: DNS A Records Explained

  1. Home
  2. Guides
  3. How to Point a Domain to Your VPS: DNS A Records E...

An A record is the DNS entry that maps a domain name to an IPv4 address. When someone types your domain into a browser, their computer looks up the A record to find out which server to actually connect to. Without one pointed at your VPS, your domain resolves nowhere, and any web server you configure on the server itself is unreachable by that domain no matter how correctly it is set up.

This is usually the first thing to get right before installing anything else. Nginx virtual hosts, Let's Encrypt certificates, and WordPress's own URL settings all assume the domain already resolves to the server; configuring any of them before DNS is in place just means redoing the verification step later. By the end of this guide your domain and its www subdomain will both resolve to your VPS, verified from your own machine and confirmed against a public resolver.

This assumes you have a running VPS with a known public IP address and a domain already registered with a registrar or DNS provider. It does not assume any web server is installed yet; if you are setting up WordPress next, the WordPress on Nginx guide picks up right after this one.

Step 1 - Finding Your VPS's IP Address

You need your VPS's public IPv4 address before you can create anything. If you already have it from your provider's dashboard or welcome email, note it down. Otherwise, find it directly from the server:

curl -4 ifconfig.me

Output:

203.0.113.42

That address is what every A record in this guide will point to. With it noted down, the next step is finding where to actually create the DNS records.

Step 2 - Locating Your Domain's DNS Management

DNS records are managed wherever your domain's nameservers point, which is not always the same company you registered the domain with. If you registered through a registrar like Namecheap, GoDaddy, or 123-reg and never changed the nameservers, DNS is managed in that registrar's own dashboard, usually under a section called DNS Management or Advanced DNS. If you moved DNS to a separate provider such as Cloudflare, it is managed there instead, and the registrar's own DNS settings are irrelevant. If you are not sure which applies, check your registrar's dashboard first; it will usually show you which nameservers are currently active for the domain.

Once you have located the DNS management screen for your domain, the next step is creating the actual records.

Step 3 - Creating an A Record for the Root Domain

The root domain (example.com, without any subdomain) needs its own A record. In your DNS provider's interface, create a new record with the following values, replacing example.com with your actual domain and 203.0.113.42 with your VPS's IP address from step 1:

  • Type: A
  • Name/Host: @ (or leave blank, depending on the provider; @ represents the root domain)
  • Value/Points to: 203.0.113.42
  • TTL: 3600, or Auto if the provider does not let you set a number

Save the record. Most providers apply it within their own systems immediately, though full propagation across the wider internet takes longer, which step 5 covers.

Step 4 - Creating an A Record for the www Subdomain

Visitors who type www.example.com need their own record too; it is not automatically covered by the root domain's A record. Create a second record:

  • Type: A
  • Name/Host: www
  • Value/Points to: 203.0.113.42
  • TTL: 3600, or Auto

Some providers support a CNAME record for www that points to the root domain instead of a second A record; either approach resolves correctly, and a second A record is simpler if your provider's CNAME handling has any quirks around root-adjacent subdomains. With both records saved, your domain and its www subdomain both have DNS entries pointing at your VPS.

Step 5 - Verifying the Records Resolve

Query the domain directly to confirm the A record is returning the right address:

dig +short example.com

Output:

203.0.113.42

Run the same check for the www subdomain:

dig +short www.example.com

If either command returns nothing or an old IP address, the record has not propagated to the resolver your machine is using yet. Query a public resolver directly to rule out local caching:

dig +short example.com @8.8.8.8

If this also returns nothing after 15 to 20 minutes, double check the record values in your DNS provider's dashboard for typos, particularly in the Name/Host field, before assuming it is a propagation delay.

Step 6 - Waiting Out Propagation

DNS changes do not reach every resolver on the internet instantly. Propagation is governed by the TTL value set on the record: a TTL of 3600 means resolvers that already cached the old value (or the absence of a record) will hold onto that for up to an hour before checking again. Most resolvers pick up the change within a few minutes to an hour; full global propagation, accounting for every resolver everywhere, can technically take up to 48 hours, though this is rare in practice for a new record with no prior value to expire.

If you know in advance you will be changing an existing record rather than creating a new one, lowering the TTL to something like 300 seconds a day beforehand shortens this window considerably, since the old, higher TTL value has to expire from caches before the lower one takes effect.

Your Domain Now Points to Your VPS

Your domain and its www subdomain both resolve to your VPS's IP address, verified against a public resolver rather than just your own machine. Any web server you configure on this VPS is now reachable by domain name rather than IP address alone. From here, follow the WordPress on Nginx guide to install the web stack, or the Let's Encrypt guide once a web server is running to serve the domain over HTTPS.

Get a VPS

Follow along with your own server. Plans from £7.98/month.

View VPS Plans

More Guides

How to Migrate WordPress from Shared Hosting to a VPS

Move a live WordPress site from shared hosting to a VPS: database export with my...

How to Set Up a Fresh Ubuntu 24.04 VPS

Step-by-step: configure a fresh Ubuntu 24.04 VPS from first SSH login to a secur...

Securing Your VPS with UFW and Fail2Ban

How to configure UFW and Fail2Ban on Ubuntu to protect your VPS from port scans...