Summary

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

We include step-by-step instructions for editing your hosts file in Microsoft Windows 8, Microsoft Windows 7, Microsoft Windows Vista, Microsoft Windows XP, Microsoft Windows 2003 and Microsoft Windows 2000.

We also show you how to edit your hosts file on Apple Mac OS X Mountain Apple Lion, Apple Lion, Apple Snow Leopard, Apple Leopard and Apple Tiger.

What is a hosts file?

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

Why would I want to edit my hosts file?

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

Modifying your computers hosts file is a useful if you wish to preview your website on DomainsFoundry 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 editing my hosts file 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).

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

What are the benefits of updating my .hosts file?

  • Easy migration. You can publish and test your site on your DomainsFoundry 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 DomainsFoundry IP address (Computer).

Mac sser? Try Gas Mark. A simple, and free hosts file manager for Mac OS X Mountain Lion, Lion, Snow Leopard and Leopard Download Gas Mark

Apple OS X Mountain Lion, Lion, Snow Leopard & Leopard

  1. Open Terminal (Click Spotlight, or press Command+Space. Now type terminal.)
  2. Copy and paste the following code into Terminal
    sudo /Applications/TextEdit.app/Contents/MacOS/TextEdit /etc/hosts
  3. Press Enter.
  4. Enter your Mac’s password
  5. Press Enter.
  6. Insert your DomainsFoundry web site’s IP and domain name. See example below.
  7. Save by pressing Command+S, click Save.
  8. Restart your browser before attempting to view your site.

Example showing adding 100.100.100.100 example.com to hosts on Snow Leopard.


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

##My DomainsFoundry Websites
100.100.100.100 example.com

Apple OSX 10.4.X Tiger

  1. Open Terminal (Click Spotlight, or press Command+Space. Now type terminal.)
  2. In Terminal type, ‘sudo pico /etc/hosts‘, press Enter.
  3. Insert your DomainsFoundry web site’s IP and domain name. For example: 100.100.100.100 example.com.
  4. Press Ctrl+X, then Y to save.
  5. Type ‘sudo niload -v -m hosts . < /etc/hosts', press Enter
  6. Type ‘lookupd -flushcache’, press Enter.
To save having to retype sudo pico /etc/hosts, when terminal opens, press the ‘up’ cursor key to scroll through the last actions.

Microsoft Windows 8

  1. Open Start Menu (Ctrl+Esc).
  2. Type “Notepage”.
  3. Right click “Notepad” and select “Run as administrator”
  4. Click Yes on the User Account Control prompt.
  5. Click File -> Open.
  6. Change the file filter drop down box from “Text Documents (*.txt)” to “All Files (*.*)”.
  7. Browse to “C:\Windows\System32\Drivers\etc”.
  8. Select “hosts” and click “Open”.
  9. Insert your DomainsFoundry web servers IP and domain name. For example: 100.100.100.100 example.com.
  10. Close Notepad. Click Save when prompted.

Microsoft Windows 7

  1. Click Start -> All Programs -> Accessories.
  2. Right click “Notepad” and select “Run as administrator”
  3. Click Yes on the UAC prompt.
  4. Click File -> Open.
  5. Change the file filter drop down box from “Text Documents (*.txt)” to “All Files (*.*)”.
  6. Browse to “C:\Windows\System32\Drivers\etc”.
  7. Select “hosts” and click “Open”.
  8. Insert your DomainsFoundry web servers IP and domain name. For example: 100.100.100.100 example.com.
  9. Close Notepad. Click Save when prompted.

Microsoft Windows Vista

  1. Click Start -> All Programs -> Accessories.
  2. Right click “Notepad” and select “Run as administrator”
  3. Click Continue on the UAC prompt.
  4. Click File -> Open.
  5. Change the file filter drop down box from “Text Documents (*.txt)” to “All Files (*.*)”.
  6. Browse to “C:\Windows\System32\Drivers\etc”.
  7. Select “hosts” and click “Open”.
  8. Insert your DomainsFoundry web servers IP and domain name. For example: 100.100.100.100 example.com.
  9. Close Notepad. Click Save when prompted.

Microsoft XP/2003/2000

  1. Browse to Start > Programs > Accessories > Notepad.
  2. Click File > Open.
  3. Browse to “C:\Windows\System32\Drivers\etc”.
  4. Select “All Files (*.*)” from the Files of Type drop-down menu.
  5. Select “hosts” and click “Open”.
  6. Insert your DomainsFoundry web servers IP and domain name. For example: 100.100.100.100 example.com.
  7. Close Notepad.  Save when prompted.