The Hosts File: What Is It, How To Edit It

What Is The Hosts File For?

The hosts file is a text file.  Your computer uses the hosts file to map hostnames to IP addresses.  You can use the hosts file to view a website before DNS changes have propagated (this can take up to 48 hours!), or before you take the site live.  Editing it is straightforward.

Editing The Hosts File

To view your site before DNS changes have taken effect, or prior to launching the site to the public, let's assume your domain name is "".
  1. Find your website's IP address in cPanel by looking at the Account Information section.  You will use the actual IP address you found, but for this tutorial we will pretend your website's IP address is
  2. In your hosts file, add a line that looks like this:
  3. When you're done previewing your site, comment out the line by placing a "#" at the beginning of the line.  Next time you need to do this, you can just delete the # and save the file.


Windows 8
  1. Click the Start button, type "notepad".
  2. Right click Notepad.
  3. Click "Run as administrator".
  4. Click "File", then "Open".
  5. Find the dropdown box set to "Text Documents (*.txt)" and change it to "All files (*.*)"
  6. Navigate to "C:\Windows\System32\Drivers\etc" and open the "hosts" file you find there.
  7. Edit the file.
  8. Save the file and close Notepad.

Windows 7 & Vista
  1. Click the Start button, "All Programs", then "Accessories".
  2. Right click "Notepad" and choose "Run as administrator".
  3. Click "Continue".
  4. Click "File", then "Open".
  5. Navigate to "C:\Windows\System32\Drivers\etc"
  6. Find the dropdown menu that says "Text Documents (*.txt)" and change it to "All Files (*.*)"
  7. Open the "hosts" file.
  8. Edit the file.
  9. Save the file and close Notepad.

Windows XP or Earlier
  1. Click the Start button, then "Find", then "Files and Folders".
  2. Find the "hosts" file in your Windows directory.  If you do not see it there, try "WINNT\system32\drivers\etc"
  3. Right click the "hosts" file, and select "Properties".  Verify that it is not "read only".  Uncheck "read only" if it is checked.
  4. Open the file with Notepad.
  5. Edit the file.  On Windows98 & Windows95, the order of the might be "hostname IP address"; on Windows2000 and WindowsME, the order will be "IP Address hostname".  Follow whichever convention is already in the host file.
  6. Save the changes and close Notepad.
If the change does not take effect you may need to reboot your computer.

Mac OS X
  1. Click "Applications", then "Utilities", then "Terminal".
  2. Open the hosts file by typing "sudo nano /private/etc/hosts"
  3. If the hosts file is locked, try this command instead: "sudo chflags nouchg /private/etc/host"
  4. Enter your user password when asked.
  5. You can add additional domains, subdomains, or addon domains after the primary, such as ""
  6. To save the file, press "ctrl"+"o".
  7. Hit enter to confirm the filename, and "ctrl"+"x" to exit the editor.

  • 19 Users Found This Useful
Was this answer helpful?

Related Articles

Let's Encrypt

NixiHost is pleased to offer Let’s Encrypt SSL certificates! These certificates are great for...


Sometimes it's useful to be able to take an image of what you're seeing on your screen for...

Joomla Optimization

These tips will help you reduce the CPU footprint of your Joomla content management system....

Free DNS Hosting

NixiHost is proud to now offer free DNS hosting to existing customers.  Our free DNS hosting is...

What happens if I exceed my allocated bandwidth?

While our Shared plans have unmetered bandwidth, our Reseller and Dedicated plans do have...