
The Windows Hosts file stores IP address and domain name pairs that help direct your computer to sites on the Internet or your local network. Browsing the Web doesn't usually require editing the Hosts file, but it serves as a basic way to block an unwanted site or a tool for tying a Web address to a website you're in the middle of developing. Set incorrectly, the Hosts file can cause websites to stop loading, so check the file for erroneous entries or erase its modifications if you have trouble connecting to some sites online.
IP Address Basics
Every website's domain name, such as "google.com," is linked to an Internet Protocol address, which locates the website's server on the Internet. As you browse the Web, a domain name server automatically looks up the IP address of each site you visit. The Windows Hosts file acts like a local domain name server, storing the IP address and domain name pairs. Domains listed in the Hosts file always connect to their listed IP addresses, completely bypassing the domain name server.
Video of the Day
Hosts File Uses
By directing a domain to "127.0.0.1" -- your own computer's address -- you block the site from loading. The Hosts file can also assign domain names to server IPs on your local network, or help you test a website before updating its name servers and making it public. When an IP is set incorrectly, however, it prevents a site from loading. When troubleshooting a non-loading Web page or a local network server, check the Hosts file entries related to the site: Incorrect entries can arise due to improper editing or viruses that use Hosts to redirect regular Web activity to dangerous sites.
Modify the Hosts File
Windows protects the Hosts file from regular editing, so you need administrative access to edit it. Search for Notepad on the Start menu or Windows 8 Start screen, right-click "Notepad" and choose "Run as Administrator." Click "File," "Open" and browse to C:\Windows\System32\Drivers\etc. To see the Hosts file, switch the file type to "All Files." The Hosts file uses one line per IP/domain pair. To add a site to the list, start a new line at the bottom of the file, type the IP, insert a space or tab and type the domain. For example, to block Facebook, type "127.0.01 facebook.com" without quotes. Changes take effect as soon as you save the Hosts file.
Hosts File Troubleshooting
Because the Hosts file directly alters the way your computer connects to websites, incorrect entries in the file cause sites to not load. If a Web page stops loading after editing the file, undo your changes. If you haven't edited the Hosts file before and run into this problem, the change might have been caused by a virus or another user's error, so reset the Hosts file by deleting everything in it starting after the last line containing "localhost," and then run a virus scan. Because some viruses exploit the Hosts file, Windows Defender, the anti-virus program included with Windows 8, flags all Hosts file edits as potential malware. If you use Defender and want to customize your Hosts file, set the file as an exclusion on the Settings tab avoid the false positive.
- Preston Gralla: Windows XP Hacks: Tips & Tools for Customizing and Optimizing Your OS
- HostGator: How Do I Change My Hosts File?
- Microsoft Support: How Can I Reset the Hosts File Back to the Default?
- Microsoft Support: Hosts File Is Detected as Malware in Windows Defender
- Google: About IP Addresses