How to test the domain before DNS change using “hosts” file

Completed the migration and don’t have a site preview  tool or is it not working?

Don’t worry. We can use advantage of “hosts” file in your local machine to test the working of your site. It is the local system file that use to map the hostname to IP before the system start looking for the DNS servers. Please follow the below steps to do this.

 

Assume your domain name is “example.com” and the new IP is “2xx.xxx.xxx.xxx”

 

If your local machine is running “LINUX” OS with GUI. Please follow the below steps.

1) Open the “Terminal” program.

2) Edit the hosts file.

sudo vi /etc/hosts

4) Save the file.

5) Now open the browser and clear the browser cache.  Call the domain “example.com“. It will load from the new IP and you can test it now! 🙂

 

If your local machine is running “Windows” OS. Please follow the below steps.

1) Locate the “hosts” file is the first part. You can find it below.

 Windows 95 - C:windows\hosts
 Windows 98 - C:\windows \hosts
 Windows Me - C:\windows \hosts
 Windows 2000 - C:windows\system32\drivers\etc\hosts
 Windows XP - C:\windows\system32\drivers\etc\hosts
 Windows NT - C:\winnt\system32\drivers\etc\hosts
 Windows Vista - C:\windows\system32\drivers\etc\hosts
 Windows 7 -  C:\Windows\System32\drivers\etc\hosts
 Windows 8 - C:\Windows\System32\drivers\etc\hosts

2) Start the notepad in “Administrative Mode” and open the “hosts” file. Please follow the below steps.

  • Find the “notepad” under programs
  • Right click on it and choose ” Run as Administrator” then locate and open the hosts file.

3) Enter the below lines at the end of the “hosts” file.

2xx.xxx.xxx.xxx   example.com  www.example.com

4) Save the file.

5) Now open the browser and clear the browser cache.  Call the domain “example.com“. It will load from the new IP and you can test it now! 🙂

 

If your local machine is running “MAC” OS. Please follow the below steps.

1) Open the “Terminal” program. You can find it under Applications >> Utilities

2) Edit the hosts file.

sudo vi /private/etc/hosts

3) Add the below lines.

2xx.xxx.xxx.xxx   example.com  www.example.com

4) Save the file.

5) Now open the browser and clear the browser cache.  Call the domain “example.com“. It will load from the new IP and you can test it now! 🙂

 

That’s it!! 🙂

Let us know if you face any issues or doubts. We will be right here for your help.

Advertisements
Leave a comment

Leave your opinion

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: