This article explains how you can quickly and easily edit your .hosts file in Mac OS X.

A hosts file is a plain-text file used by your Mac to map hostnames to IP addresses.

Modifying your computers hosts file is a useful if you wish to preview your website on Ecenica without modifying your domain name. Editing your hosts file can also be useful after registering a new domain name, recent domain transfer or DNS update. See How long does it take for my domain name to become active?

How does it work?

When you view a website your computer looks at it’s .hosts file to try and map the site host-name to an IP address. If a match is not found, your computer tries to find an IP address using the Domain Name System (DNS).

Editing your .hosts file let’s you intercept the DNS lookup and redirect your domain to another IP address.

The computer at the receiving IP address needs to answer to your domain name.

Why update my .hosts file?

  • Easy migration. You can publish and test your site on your Ecenica web space without taking your old site offline.
  • Faster web development. You can develop and test your site on your local server using your domain name.
  • Redirect your domain to a local IP address.
  • Simple and easy to use.

How do I change my .hosts file?

To view your website before updating your domain’s name servers or DNS records you will need to change your HOSTS file to point to your Ecenica IP address (Computer).

On Mac? Try Gas Mask. A simple, and free hosts file manager for Mac OS X Download Gas Mark

Apple OS X

  1. Open Terminal (Click Spotlight, or press Command+Space. Now type terminal.)
  2. Copy and paste the following code into Terminal
    sudo nano /etc/hosts
  3. Press Enter.
  4. Enter your Mac’s password
  5. Press Enter.
  6. Enter your Ecenica web site’s IP and domain name. See example below.
  7. Finish by pressing Ctrl+X and Y to save.
  8. Restart your browser before attempting to view your site.

Example host file with added.

# Host Database
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##       localhost broadcasthost

##My Ecenica Websites

To save having to retype sudo nano /etc/hosts, when terminal opens, press the ‘up’ cursor key to scroll through the last actions.