How can I edit my hosts file?

Sometimes you may need to modify your hosts file, especially if you are trying to preview a name based site before dns propagation occurs.  This entry details the steps you need to take to make the changes you need.

The hosts file is basically a shortcut for bypassing the standard DNS lookup that your computer would normally do to see where a website is hosted. For example, If you want to access a development version of your website to test it before going live, you can modify your hosts file to redirect only your computer to the delopment server.

The hosts file is a simple text file, and this contains IP addresses separated by whitespace (space, tab, etc) in UNIX/Linux or a single space (Windows) and then the domain name.

Here's an example:

The location of your host file depends upon your operating system.  Here is a list of common operating systems and the location of the host file in each:

  • Windows NT/2000/XP/Vista/Windows 7: c:\Windows\System32\drivers\etc\hosts
  • Unix/Linux: /etc/hosts
  • Apple: System Folder: Preferences


You will need administrator privileges to edit the hosts file in Windows, and root under most UNIX-like systems.  Once you are logged in with administrator access, follow these steps to modify your hosts file:

1.  Windows Start - find/search notepad.  Right click on notepad and choose "run as administrator"

2.  From within notepad choose "File - Open" and then browse to c:\Windows\System32\drivers\etc\hosts, click open.

3.  You'll enter your IP and then domain name in the format like in the example above. There is a space in-between the IP number and domain name, and this is very important.

4.  Save the file and then close, and re-open your internet browser.

To revert back how your host file was setup previously, simply remove your newly created lines/changes from the host file and then close and open your internet browsers.

The above steps are the same under UNIX/Linux using your text editor of choice and adjusting the path as mentioned earlier.

Please be careful not to change the following entries in hosts

# localhost name resolution is handled within DNS itself.

# localhost
# ::1 localhost

ReviewedL 10/26/2016

  • Email, SSL
  • 21 Users Found This Useful
Was this answer helpful?

Related Articles

What if I need more hard drive space or bandwidth? - delete

Submitted by user: I need more HD space.. There are a few other companies out there that are...

What language can I program in? Where can I download scripts?

For the most part PHP is the most common scripting on the web. Many other scripts and programs in...

Help - my site's been infected by a Virus

The viruses that attach themselves to web pages are unfortunately common, and though they are...

Fix for FrontPage hit counter on subdomain

Problem: You're using MS Front Page with web bots. The hitcounter works fine on your main domain,...

Can you tranfser files from my old host to you?

If your current web hosting provider has cPanel all you would need to do is create a BACKUP of...