How to Edit the HOSTS File in Windows 7, Vista, and XP

Business man working on computer
AMV Photo/Digital Vision/Getty Images

The HOSTS file is the virtual equivalent of the phone company's directory assistance. Where directory assistance matches a person's name to a phone number, the HOSTS file maps domain names to IP addresses. Entries in the HOSTS file override DNS entries maintained by the ISP. This makes the HOSTS file a common target of malware. By modifying the HOSTS file, malware can block access to antivirus updates or force you to a malicious website.

It's a good idea to check the HOSTS file periodically. Here's how to find - and edit - the HOSTS file on Windows 7, Vista, and XP.

Difficulty: Easy

Time Required: Less than 10 minutes

Here's How

  1. Open Notepad

  2. Click File | Open in Notepad and browse to:

  3. Make sure the etc folder is highlighted (selected). Now change the file type so it reads "All files". You should now see the HOSTS file appear in the directory list.

  4. Double-click the HOSTS file and it will open in Notepad for editing.


  1. In Windows 7, you will not be able to save edits to the HOSTS file unless you open it directly from Notepad (follow the steps described above).

  2. If you have difficulty saving the modified HOSTS file, check the file's attributes to see if it's been marked Read Only.