View Site Before DNS Change Using HOSTS File

View site before DNS change hosts file
This article will help you to view the site before DNS change or DNS propagation.We can use the advantage of the “hosts” file in your local machine to test the working of your site.

Completed the migration and don’t have a site preview tool, or is it not working? So how to view the site before DNS change or DNS propagation? Don’t worry. We can use the advantage of the “hosts” file in your local machine to test the working of your site. It is the local system file that maps the hostname to IP before the system starts looking for the DNS servers. Please follow the below steps to do this.

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

 

If your local machine is running LINUX :

1) Open the “Terminal” program.

2) Edit the hosts file.

sudo vi /etc/hosts

 

3) Save the file.

4) 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 :

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

Windows 95 - C:\Windows
Windows 98 - C:\Windows
Windows Me - C:\Windows
Windows 2000 - C:\Windows\System32\drivers\etc
Windows XP - C:\Windows\System32\drivers\etc
Windows NT - C:\Winnt\System32\drivers\etc
Windows Vista - C:\Windows\System32\drivers\etc
Windows 7 - C:\Windows\System32\drivers\etc
Windows 8 - C:\Windows\System32\drivers\etc

 

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 :

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!

 

If you want to test this on your Android, iPhone, or other mobile devices :

Most phones won’t allow you to modify the system files unless it’s a rooted phone. But don’t worry, there is another way to do this. I assume you are accessing the web using WiFi, and if that is the case, there must be a WiFi router. You can make such changes to this router itself. Most routers have a GUI control panel, and you can set, edit and manage DNS records for your local network from here.

Share this post

Services to Explore

Stay up to date!

Stay up to date with the Web Hosting, Cloud and Server Management Industry News and Tutorials!

We will send you only the relevant emails, and we respect your privacy. Please review our privacy policy for more info.

Linux Management Services

Focus on your business, and let us take care of your Linux Servers!
From what you are reading, it seems you are interested in Linux and related technologies. If you have a moment to spare, please take a look at our Linux Management Services plan, which might interest you even more!
Linux Management Plan

Value-Added Services

We have services that can help you run a successful business. With us, you don't have to worry about these areas because our experts will take care of it for you.

Introducing - WPHealers!

Complete WordPress Management, 24x7 Support & White Label Agency Plans!

WordPress migration service, security, white-label reseller services and lot more! Grab the introductory deals now!

WPHealers

ServerHealers uses cookies.