What is the HOSTS file & when should I use it?

Editing HOSTS file on OS X via NanoWhat is the HOSTS file?

The HOSTS file is used by your computer’s Operating System (Windows, OS X, Linux, etc) to map hostnames to IP Addresses.  In layman’s terms your computer will check this file for any domain it needs to resolve to an IP Address prior to querying public DNS resolvers.  The HOSTS file can be used to point a domain name to an IP Address regardless of the DNS settings for the domain.

An example of a HOSTS entry to load “www.example.com” and “example.com” from the IP address ““:    www.example.com example.com

Windows may require two separate lines like so:    www.example.com    example.com

When the above records are added to your HOSTS file the result is that if you try to load that domain in your browser it will connect to that IP to make the request.  If you try pinging the domain you will find that it pings that IP as well.  What this means is that you can use this to test your site on a new server before you point your world-wide DNS there. Continue reading “What is the HOSTS file & when should I use it?”