A domain name is only a label. To make example.com open your website, you add a DNS record that tells the internet which server holds it. For a VPS that record is an A record pointing at your server's IP address. You make the change where your domain's DNS is managed, which is usually your domain registrar or a service such as Cloudflare. You do not change anything on the VPS to do it.
What you need
- Your server's IPv4 address. It is on the Network & access tab of your server page in the client area.
- Access to your domain's DNS settings.
Add the records
Open the DNS or "Manage DNS" page of your domain. Create these records, replacing the address with your server's IP:
- Type A, name
@, value your IP address. This points the bare domain,example.com. Some panels show the name as blank or as the domain itself. - Type A, name
www, value your IP address. This pointswww.example.com. You can use a CNAME toexample.cominstead, but a second A record is just as good.
Leave the TTL at its default. Delete any old A record for the same name, because two records pointing to different servers will send visitors to both.
How long does it take?
Often a few minutes, and sometimes up to a few hours, because other networks keep the old answer until its TTL ends. Lowering the TTL to 300 seconds a day before a move makes the change spread faster.
Check that it works
From your own computer, ask a DNS server directly:
nslookup example.com
On macOS and Linux, dig +short example.com prints just the address. When the answer is your server's IP, the record has taken effect. Then open http://example.com in a browser. If Nginx is set up, you should see your site.
Subdomains
To use app.example.com, add an A record with the name app and the same IP address. Then add that name to the server_name line in your Nginx file.
If it does not work
- The lookup shows an old address: wait, or try a different DNS server such as
nslookup example.com 1.1.1.1. - Your browser still shows the old site: clear the browser cache, or try a private window. Browsers cache DNS answers.
- You changed nameservers, not records: if your domain uses Cloudflare or another DNS host, add the records there, not at the registrar.
- Cloudflare's proxy is on (orange cloud): the lookup shows Cloudflare's addresses instead of yours. That is normal, but switch it to DNS only while you are getting your first certificate.
Next steps
Once the domain reaches your server, add a free SSL certificate so the site loads over HTTPS. If you are serving a Node.js app, follow hosting a Node.js app with PM2 and Nginx first.