Domain Names, Getting Started

How to edit hosts file in Mac & Windows

 

Summary

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

This article shows you how to edit your .hosts file in Mac OS X and Windows.

Modifying your computers hosts file is a useful if you wish to preview your website on Ecenica Hosting 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 Hosting 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 Hosting IP address (Computer).

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

Apple OS X 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. Insert your Ecenica Hosting web site’s IP and domain name. See example below.
  5. Save by pressing Command+S, click Save.
  6. 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 Ecenica Hosting 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 Ecenica Hosting 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.
Tip: 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 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 Ecenica Hosting 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 Ecenica Hosting 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 Ecenica Hosting web servers IP and domain name. For example: 100.100.100.100 example.com.
  7. Close Notepad.  Save when prompted.

This page is wiki editable click here to edit this page.

Sponsors

Web Hosting – £2.99/mo

Reliable UK web hosting. Free tech support. Trusted UK host since 2004. Free setup. Order online.

http://ecenica.com/

cPanel Hosting – £4.99/mo

Fast cPanel hosting with email. Choice of UK/US servers. 30-day money-back promise. Founded 2004.

http://ecenica.com/

 

Related posts:

 

Tags: , , , , , , , , , , , , , , , , , ,

Share this article

If you found this article useful, please feel free to re-tweet. The Bit.ly Url for this post: http://bit.ly/9bIMGn.

Leave a Reply

You must be logged in to post a comment.

Still need help?

Please login to account and submit a new support ticket.

Copyright

Unless stated, this article is subject to Ecenica Hosting copyright protection. We've worked really hard to bring you this site so before you click copy & paste please take a moment to read our Copyright Notice.

Back to Top