Hi, you need an A record. Here is how to do it.
- Find where your domain's DNS is managed. If you use the nameservers of your registrar, log in there. If you use Cloudflare or your host's nameservers, log in to that one instead. The records only work in the place where your nameservers point.
- Open the DNS Zone Editor (in cPanel) or the DNS settings page.
- Add an A record for the main domain:
Type: A
Name: @ (or leave it blank, or type yourdomain.com, depends on the panel)
Value: your VPS IP address
TTL: 3600 (or Auto)
- Add another A record for www:
Type: A
Name: www
Value: your VPS IP address
TTL: 3600 (or Auto)
You can also make www a CNAME record that points to yourdomain.com. Both ways work.
- Save and wait. It usually takes a few minutes, but it can take up to a few hours to spread everywhere.
If the domain already has an old A record, edit it instead of adding a new one. Two A records with different IPs will split the traffic between them.
Also, your VPS needs a web server (like Nginx or Apache) with a virtual host set up for your domain, or you will only see the default page. DNS only sends people to the server. It doesn't set up the site.
To check if it worked, open a terminal and run this:
ping yourdomain.com
The IP it shows should be your VPS IP. If you still see the old IP, wait a bit more or clear your local DNS cache.