At some point in time, every business will need to move their website to a new hosting provider. Mostly this is accompanied by a new website design or update to the existing CMS.
It is important to make sure that the website is up and running without any glitches before you switch the DNS to the new server and make it available to the whole world.
Here are the step-by-step instructions to preview a website on your new website hosting before switching DNS.
The most common method to inspect a website before migrating is by modifying hosts file.
The hosts file is a local computer file used by an operating system to map hostnames (domains) to IP addresses. Editing this file allows you to override your computer’s DNS system for a domain on a certain machine. This way you can edit or work on your website hosted on the new server while your users are still directed to the active website on the old server.
Note: Before changing files, close the browser.
Here’s how you can edit hosts file on different operating systems:
For Windows 7, Windows 8 and Windows 10 Users
- Locate the hosts file on your computer. For windows users, it is typically located at;
- Double-click on the ‘hosts’ file and choose Notepad from the list of available programs to open the file with.
- Type in the IP of your new web host and then your domain name in the following way:
Here, IP_address is the IP address of your account on the server and domainname.com is your actual domain name.
- When finished, save changes.
- Next, clear the browser’s cache and re-open your domain name on the new server to see the changes.
Alternatively, you can:
- Open Notepad with Administrative privileges by clicking the Start
- Find Applications> type Notepad in the search bar and then right-click on Notepad and select Run as Administrator.
- In Notepad, click the File menu > choose Open.
- Browse to Folder C:\Windows\System32\drivers\etc. Alternatively, you may also copy the given path onto the address bar and click Enter.
- Click All Files to locate the hosts file.
- Follow the steps 2-6 as mentioned in the previous instructions.
For Mac Users
- Open Terminalinside of your Utilities Folder either by clicking Applications > Utilities > Terminal or simply typing Terminal on the Spotlight.
- Back up your existing hosts file to be on the safe side. Copy and paste the following command and hit return:
sudo cp /private/etc/hosts /private/etc/hosts-orig
- After you have a backup copy, you can edit your hosts file. Copy and paste the following command and hit return:
sudo nano /private/etc/hosts
- Type your user password when prompted.
- Your hosts file will appear on the screen which looks something like this:
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
- Edit the hosts file by adding your domain name and IP address below the default ones in the following way:
- After you have made the changes, press Control + O to save the file, Control + Xto exit the editor.
- You need to now flush your DNS cache by typing the following command and pressing return:
Once done, close your browser, and re-open to view your website on the new server.