If you are looking for your hosts file, either you are somewhat technical with computer networks and you use the hosts file and thus familiar with what it is, or you are a typical user and something in your system is telling you that it cannot find the hosts file. Hopefully it is the former, but most likely it is the latter, or it could be both.
In any case, the goal of this article is to help you recover.
Where is the hosts file?
First we need to make sure we are looking in the right spot. The operating system knows where to look because the registry tells it where the "hosts" file is stored:
DataBasePath = %SystemRoot%System32\drivers\etc.
By default, this path is c:\windows\system32\drivers\etc. This is true for Windows 2000 all the way up to Windows 7.
Restoring the hosts file
Now that you know where the hosts file is or is supposed to be, you’ll want to double check if it is there or if there is some form of back up there. If you find a file that looks like a backup of your hosts file, then copy that file to a file called "hosts". If you aren’t sure, then don’t. Note that the "hosts" file has no extension, so make sure this is the case. The hosts file backup (if any) is a basically text file (as is the original "hosts" file). It may be called hosts.bak or something similar. All you need to open and read it is the Windows Notepad program.
If you can’t find the hosts file and a backup doesn’t exist, then you’ll have to create a new "hosts" file. To create one, you’ll need to open the Windows Notepad program and enter the following information in it:
The "1" in the "127.0.0.1" must be at the very first column of the line. Also, there must be at least one space between "127.0.0.1" and "localhost". The second line is an IPv6 address mapping to localhost, and this line is part of the default hosts file for Windows Vista and Windows 7. There must be at least a space between "::1" and "localhost".
In Windows 2000 or XP, all you need to do to save this file as "hosts" and you are done. In Windows Vista or 7, you must have started the notepad program "as Administrator". This will allow you to save to the "hosts" file and the path where you are trying to save is a system type file.
Once you’ve created the new hosts file, you are done and you’ve basically recovered. If you had some IP address-name mappings in the original hosts file for your computers in your home network, then you may append them to the hosts file; each mapping must have its own line.
IMPORTANT: The hosts file typically doesn’t disappear on its own. There should be nothing touching that file, unless you explicitly decided to modify it or you have a computer security program that modifies it to prevent you from going to malicious web sites. Thus, you should do a full system virus/malware scan as your computer may be infected! Just do this as a precaution.
To quickly recover from your missing host file, you’ll need to create a new one in c:\windows\system32\drivers\etc and put some default entries in it. This will get your computer to its baseline hosts file configuration. You may also append other IP address-name mappings you may have had in the original hosts file. As a precaution, it is recommended that you do a full virus/malware scan of your system as nothing should be touching your hosts file; the fact that your hosts file disappeared may be a symptom that your computer is infected.