How to test a website before changing nameservers

Posted on by in Krystal Tech

If you are moving your website and want to test out the setup on the new hosting before changing your nameservers or DNS settings on the domain then read on to discover how to get started.


In this post we are going to explain how to view your website before moving the domains records over from another location. This method will enable you to build and test a new website on our hosting and then move between different hosts with little to no downtime.

In our examples we are going to use an example domain “” and the I.P address assigned to the site is ““. The actual details for your domain will be in your cPanel hosting welcome e-mail.

DNS in 60 seconds.

Before we jump straight into the solution, lets quickly go over the basics of DNS so we can understand what we are doing. If you already know about nameservers and DNS, then skip this section!

The internet is one massive network. Each node connected to this network has a unique I.P address. These addresses are used to send information to the correct place. At the moment the majority of the internet is still based on IPv4, which means that addresses are made up of 4 numbers such as:

Humans aren’t good at remembering numbers that have no relevance to what the address means to them. Imagine telling your customers that your website address was – they’d never remember it. Humans are good at remembering short and concise words or phrases they can relate things to. That’s where “DNS” – Domain Name System comes in. DNS turns meaningful web addresses like “” into an I.P address that your computer can use to communicate with.

When you set your nameservers on your domain you are telling the world where to find all of the DNS entries for your domain – where to find your website and where to send e-mail.

Overriding DNS records

To start testing our domain on the new server, we want to instruct our local computer to ignore the DNS records found publicly on the domain name, and set our own records. This is done using the hosts file. Every operating system has one, and it’s a simple text file in where you can enter I.P addresses and domain names or subdomains.


The hosts file in located at C:\Windows\system32\drivers\etc\hosts 

This file is often set with read only permissions by system protective software as it’s an easy avenue of attack if your system is compromised. If your system was compromised, anyone with access could redirect you to any site that they wanted by entering false details in your hosts file. You’ll need to take off the read only permissions to make changes if it is set.

The default hosts file will look similar to this:

All we need to do is insert new records for our domain name at the bottom of this file. We add one for the domain name, and one for the www. record of the domain name.

Once you’ve saved this file, your computer will no longer go off and ask for DNS records for the domain name, but will simply use the address in the file. If you wish to remove the records, then load up the file and remove them, or add # to the start of the line to comment it out.

Linux and MacOS

The syntax for Linux and MacOS is exactly the same as Windows. The file will be located at /etc/hosts and will be protected, so you’ll need to edit it as a superuser, or as root. Open a terminal and type:

Use exactly the same syntax as in Windows, entering the records at the bottom of the file and then save the file.


The hosts file may already contain records such as

Make sure you don’t remove these records, as you will cause problems with your system.

Remember that by adding these records to your system, the old website will cease to function for you until you remove them again. This could affect your ability to collect your e-mail as well as other things, so bear this in mind.

Also tagged as , , , , , ,

Why not try browsing our blog by category?