How to test our website with the hosts file before changing DNSs

If you are planing to transfer your website from your current hosting company to one of the CooliceHost's web hosting servers, you need to test first before changing the DNS records or in other words - to point the domain. Here you will get information of how you can migrate your website to us and test it without making any changes to the domain's DNS records. The only thing you need do know is the Internet Protocol (IP) of your new server (this information is included in your order confirmation email we send to you once you order the hosting plan you want).

As you know the hosts file refers to several system facilities that assists in addressing network nodes in a computer network. It is a main part of Internet Protocol (IP) implementation of any OS. It help to translate numeric protocol addresses, identifying and locating a host in an IP network. The default hosts file has already created record of your localhost with IP address

Editing the hosts file in Linux

Linux distributions or most of them use the hosts file at /etc/hosts. You should have root/sudo access to edit this file or you won't do anything here. Use some editor to open the file or reach it from your terminal (sudo nano /etc/hosts command). Usually it looks something like this: localhost
::1 localhost ip6-localhost ip6-loopback

You can add your domain for testing purposes in the hosts file, you need to specify what domain points to which IP address (the given IP - is an example, you have to use the IP of your new server where your website will be). You will need to add the line:

The hosts file looks like this after you the editing process: localhost
::1 localhost ip6-localhost ip6-loopback

Or.... localhost
::1 localhost ip6-localhost ip6-loopback

It should look like that:

Changing DNSs

Save the file. In the terminal - Ctrl + X and than press Y for Yes. All requests for the domain and will direct to the specified IP (

Editing the hosts file in Windows

In Windows 7 and higher versions, the hosts file is located here %SystemRoot%\system32\drivers\etc\hosts, where %SystemRoot% is the directory where Windows has been installed. It should be: C:\Windows\System32\drivers\etc\hosts. You can edit the file with notepad, you should have admin permissions to edit it. Follow these steps:

1. Click the Start menu in the bottom left.
2. Select All Programs.
3. Go to Accessories.
4. Right-click on Notepad and choose Run as administrator.
5. Browse to the following path: %SystemRoot%\system32\drivers\etc\ (Default: C:\Windows\System32\drivers\etc\).
6. You will need to choose that instead of showing Text Documents (*.txt) you will see all files in the directory.
7. Open the hosts file.

Now add new entries after the comment lines that starts with #. After editing, the file should look like this:

# localhost name resolution is handled within DNS itself.
# localhost
# ::1 localhost

Editing the hosts file in Mac OS X

The hosts file in Mac OS X is located at /etc/private/hosts. The proper way to edit it by using the Terminal. You can do this either by typing "Terminal" into Spotlight or by opening Finder and navigating to Applications > Utilities > Terminal. To open the hosts file for editing, type:

sudo nano /etc/private/hosts

The file looks the same as in Linux or any other *nix system. You can add the the new IP for the domain: localhost
::1 localhost ip6-localhost ip6-loopback

Or.... localhost
::1 localhost ip6-localhost ip6-loopback

Testing the hosts file

If you are not sure if all you have done is working properly, you can test it by pinging the domain in your Terminal. That way you will see does the domain is pointing to the correct IP you have added in your hosts file. Here is what you should type:


The response in most case looks like this (from the new configured IP):

PING ( 56(84) bytes of data.
64 bytes from ( icmp_req=1 ttl=58 time=1.30 ms
64 bytes from ( icmp_req=2 ttl=58 time=1.41 ms
64 bytes from ( icmp_req=3 ttl=58 time=1.36 ms
64 bytes from ( icmp_req=4 ttl=58 time=1.66 ms

If you use Linux or Mac OS X, you can use ping from the Shell or Terminal respectively. In Windows, you will need to open the command line: Press CTRL + Windows button on the keyboard. In the pop-up window, type cmd and hit enter.

Was this article helpful?

mood_bad Dislike 0
mood Like 16
visibility Views: 3540