Editing the hosts file in Windows 7
Editing the hosts file
The hosts configuration file on Windows is used to manually specify DNS records.As easy it may seem, editing the hosts file can be a little bit tricky. You don’t believe me ? Try and edit your file. It’s located here
%systemroot%\system32\drivers\etc\
But I can’t see any files there
Well, that’s because by default you can’t see hidden files on the file system. You can change that from here :
Ok, I tried to edit it. It’s in use by another application
"The document C:\Windows\System32\drivers\etc\hosts is in use by another application and cannot be accessed."
My first reaction to that was to check if some process has actually locked it. My second reaction was to install a very cool program called Unlocker that allows me to move, rename and delete a file even if it’s in use by the prime-minister. Unfortunately, that didn’t help either. Which brings us to rule number 2, which is…
Even if you are an administrator, you can’t rule the world (by default)
The ugly truth is that even if your account is from the Administrators group, you still can’t use all your privileges. That is what happens in our case. The hosts file is not used by another program, it’s just that you don’t have the necessary permissions to edit it. So what you need to do is the following :
and then open the file manually from Notepad.
But I still can’t see the files in my Open window…
That’s because by default it shows only textual files. Just check the "All files *.*" option.
Configuration
OS: Windows 7 x86
Another good solution to editing the hosts file under Windows 7 is to download a program known as HostsXpert. It offers line-by-line editing and most importantly the option to backup or restore (to default) the hosts file.
Hi Sebastian,
Thanks for the comment, I've never heard of that program. I guess if you think you need a more elaborated way of dealing with the hosts file, it's definitely the better option.
Regards,
Kosta
I was having this issue also. Something that helped me was to try to delete the host file, then it tells me what program is using it. In my case it was my firewall accessing the host file. So what I did was disable firewall from task manager and saved updated host file.
@James
Thanks for the suggestion James. Worked for me!
Thanks James.. I was struggling with that for a couple days and that worked perfectly.