When you buy a VPS server, you can access it with an IP address. This tutorial will show you how to access the server with a domain name instead.
Setup: Domain Points to Something Else
Say you have a DigitalOcean VPS, and an IP address to access it. For example, I’ve just set up Apache on a server with IP address:
206.189.233.82
I can access it in the browser via the IP like this:
For this example article, I have a domain name with Bluehost, which comes free with every plan. (Here’s the Bluehost yearly cost for hosting). Currently the domain is “testbluehostaccount.com” and it points at a WordPress installation on Bluehost’s servers:
In this situation, I have:
- VPS Hosting with DigitalOcean – IP address 206.189.233.82
- Domain hosting with Bluehost as the domain registrar
What I want to do, is point “testbluehostaccount.com” to my VPS server at DigitalOcean. Here’s how to do it.
Step 1: Find the Zone Editor with your Domain Registrar
First, log into your domain registrar’s dashboard. This will be different for each registrar. GoDaddy, SiteGround etc, all have their own interfaces. But they should be quite easy to find. Most of them have a “Domains” section, under which they keep the zone editor.
For Bluehost as well, you can find it under “Domains” like this:
This will take you to the page where you can choose which domain you want to edit. If you have just one domain (like I do), there’ll be just one choice in the dropdown box:
Choose the domain that you want to point to your VPS.
Step 2: Edit the Zone File Records
To point the domain to our VPS, we need to change the “A” record in the zone file editor. Basically, the settings are:
- Host Record Name: @, or the domain name itself
- Record Type: A
- Points to: 206.189.233.82 (or your VPS IP)
You probably already have a record in your zone file editor pointing the domain to some other IP address like this:
Don’t create a new zone record! Modify the existing one instead. As you can see with Bluehost, you can click the gear icon on the right-hand side to edit it. The “@” is a wildcard that stands in for the domain name itself. Most hosts support it, and it’s easy to remember. Enter the IP address of your new VPS server instead, and save your changes:
What About the Other DNS A Records?
A DNS zone file will likely contain many other records, and not just one “A” record. The others are for specific subdomains. If you want each of these subdomains to point to your VPS server, then change the IP address for each of them. A few common subdomains are:
- webdisk
- etc etc..
The “CNAME” records are alias records. They tell the DNS server which names are equivalent. So the “www” CNAME entry just points to the domain name itself, and so on. You shouldn’t need to change any CNAME records unless you know what you’re doing.
Step 3: Verifying that the Zone Record Has Changed
Once you’ve saved your new IP address in the zone record, you can verify that it’s changed on that particular name server like this.
Get the Nameservers of your Registrar
Your registrar will typically have two namesevers. With Bluehost, you can get the details by clicking “Domains”, and then choosing the “name servers” tab as shown here:
The two name servers for Bluehost are:
- ns1.bluehost.com
- ns2.bluehost.com
These will be different for each domain registrar.
Step 4: Verify the Modified “A” Record
In Windows, open the command line and enter the following:
nslookup [your_domain_name] [nameserver]
So for me, the command looks like this:
nslookup testbluehostaccount.com ns1.bluehost.com
If you’ve changed the records correctly, the output should tell you that your domain is now pointing to the VPS IP address as shown here:
Your work is done.
Step 5: Waiting for the Changes to Propagate
Unfortunately, you still might not be able to access your VPS with the domain name immediately. DNS changes take time to propagate to all the other DNS servers in the world. You can track the propagation status of DNS servers all over the world, with this tool.
As you can see below, some servers have received the new IP address, and others have not:
If your browser or machine queries a DNS server that has been updated, you’ll see the new site when you type in your domain name like this:
Keep in mind that some browsers, routers, and even ISPs cache DNS queries, and this can make it difficult to get updated results. There’s not much you can do, other than be patient.
Do I Buy SSL from my Hosting Provider, or the Domain Registrar?
You should be able to get free SSL from your hosting service. These days, no one needs to pay for SSL anymore, and SiteGround, Bluehost, Hostgator, all provide free Let’s Encrypt certificates. All, with the exception of GoDaddy!
And that’s it. You’ve successfully modified your DNS zone records to point a domain name at your VPS server. Now you can access it by typing in your domain name instead of with an IP address!
Speak Your Mind