Recipe 13.1. Using a HOSTS File to Speed Up Web Access


You want to increase the speed at which you connect to web sites.


The HOSTS file is a plain text file that you can create or edit with a text editor like Notepad, and that resolves hostnames with their corresponding IP addresses, without having to go out to a DNS server. To use it to speed up web access:

  1. Run a text editor like Notepad or Wordpad.

  2. In your text editor, open the file called HOSTS in %SystemRoot%\System32\Drivers\Etc\HOSTS. The file has no extension; it is named only HOSTS. If the file doesn't exist, create it.

  3. Enter the IP addresses and hostnames of your commonly visited web sites. Each entry in the file should be on one line. The IP address should be in the first column, and the corresponding hostname in the next column. At least one space should separate the two columns. It should look like this: 216.92131.107

  4. If you'd like, add comments to the file by preceding the line with a #, in which case the entire line will be ignored by the file, or by putting a # after the hostname, in which case only the comment after will be ignored. You might want to comment on individual entries for example:    #still in beta

  5. When you're finished editing the file, save it to its existing location.


One of the causes of slowdowns in accessing web pages is the way that your PC uses the Domain Name System (DNS). The Internet can't understand plain English words that you use to visit a web site, such as Instead, it needs to know the numeric IP address. So whenever you type in a hostname, such as, that address needs to be resolved to its IP address, such as DNS servers automatically provide that name resolution.

It takes time to send your request to a DNS server, have the server resolve the IP address, and then send the IP address back to your PC. You can speed up the process by creating or editing a local HOSTS file on your own PC that contains hostnames and their corresponding IP addresses. When you create one, XP will first look into the HOSTS file to see if there's an entry for the hostname, and, if it finds it, it will resolve the address itself. That way, you won't have to go out to a DNS server and wait for the response before visiting a web site.

You'll frequently come across software on the web that promises to speed up Internet access by changing a variety of "hidden" settings on your PC. It's questionable whether changing these settings has much of an effect on Internet speed, especially if you have broadband, such as a cable modem or DSL modem. And many of these programs also make changes to your HOSTS file, which, as this recipe shows, you can do yourself. So be wary of paying for Internet speed-up programs, because it's not clear that they actually have much of an effect.

If you use this recipe to edit your HOSTS file, make sure that you check the file regularly and keep it up to date, or else you may deny yourself access to certain web sites. For example, if the web site were to change its IP address, but your HOSTS file kept the old, incorrect address, your browser would not be able to find the site, because it would be given the wrong addressing information.

See Also

For information about how you can use the HOSTS file to block ads on the Internet, see the O'Reilly WindowsDevCenter article "Kill Internet Ads with HOSTS and PAC Files" at

Windows XP Cookbook
Windows XP Cookbook (Cookbooks)
ISBN: 0596007256
EAN: 2147483647
Year: 2006
Pages: 408

Similar book on Amazon © 2008-2017.
If you may any questions please contact us: