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.