Emulate DNS Change through Hosts on PC

When you have just moved website to a new web host and updated the DNS name servers or A records for your domain, you may want to know how your site works on the new server at the first fime so you can troubleshoot any problem or error of your website at promptly. However since any DNS change takes some time to propagate, you cann’t view the change immediately. If you simply change DNS records, it may take couple of hours for DNS propagation. See how to edit DNS A record with GoDaddy. For domain name servers change however it can take up to 72 hours (usually less) for that to take effect across the internet. See how you can change name servers with GoDaddy. This is bad if your website did not work on the new server and you can’t let your site down for three days. Here is one trick to emulate DNS change on your local computer. It is highly recommend you to emulate the DNS change for your domain before you transfer domain name, change its DNS records or name servers. Only when your websites have been tested to be working fine should you change or transfer the domain name.

Emulate DNS Change for your Domain

Every time you access a domain name, DNS translates the human language into machine’s language, from domain name into the corresponding IP address. You can find more about what is DNS and web hosting basics here.

DNS change emulation is to emulate what the website will look like as if you had made the DNS change. Instead of using the public DNS service, you can make use of a local file on your computer to manipulate the DNS. There is a file on your computer called ‘hosts’ which allows you to to do that. You can edit this file to override DNS for any domain name. There will be two steps to achieve that. Firstly you need to find out your new website address, secondly you need to edit the hosts file on your computer to point your domain to the new server IP address.

Locate new server IP Address

Every device connected to the web has its own unique IP address. For example, you can find IP address on your iPad, find IP address on Mac here. Your web server and websites hosted on it has its own IP address as well. When you subscribe a web hosting service, your web host should send you an order confirmation email with server IP, hosting account login credential, FTP and other important informatin included. If you use a cPanel hosting, such as Bluehost, Arvixe hosting, Inmotion hosting, you can refer to this tutorial to find out your website server IP address in cPanel.

Emulate DNS Change for your Domain

If you are on Windows OS, the hosts file can be found from C:\WINDOWS\system32\drivers\etc. If you are using Windows 8 or 8.1, Windows 7, Vista, XP, you can locate this folder from Windows Explorer, and open this file using a text editor, like Notepad.

edit hosts file on pc

Start a new line in the hosts file with the format of “ipaddress domain.com”. See above screenshot. Then save the change and you are done. If you are on a Mac, the steps will vary. Once you have updated the hosts file on your computer, go to browse your domain in any web browser on your computer, your domain will be pointed to the new server IP address and you can see how your website runs on the new server immediately. So when you decided to move websites to new server, you can use this method to migrate your website files at first, then test it on the new server by emulating DNS change, after that you can edit the DNS of your domain and add it to your new host as well.


Leave a Reply