View website domain before DNS A record is changed on Mac OS X Yosemite and Mavericks

You’re developing a site on a sub-domain or development server that is setup something like this, dev.YourDomain.com and you want to see if all the files and paths are correct. You’ve moved the site to a new server and IP and you want to check YourDomain.com there without disrupting the live site. Simply edit your /private/etc/hosts file on your Mac OS X box to reflect the new IP you want to test.

Real Live Site: YourDomain.com IP 2.2.2.2
Dev Site: dev.YourDomain.com IP 3.3.3.3
DNS Masked Site: YourDomain.com IP 4.4.4.4

Simply edit /private/etc/hosts and add the line

4.4.4.4 yourdomain.com www.yourdomain.com

Now when you ping yourdomain.com your system will return 4.4.4.4. Open up your browser and test your new site before making the DNS switch on the real DNS servers.

The hosts file is used to map hostnames to IP addresses. With the hosts file you can change the IP to which you resolve a certain domain name.

This is particularly useful when you wish to see how a website will look when hosted on a different server without having to wait for a DNS change to propagate, or avoiding any DNS changes at all.

Leave a Reply

Your email address will not be published. Required fields are marked *