Home > Administration > Editing the hosts file in Windows 7

Editing the hosts file in Windows 7

February 27th, 2013 Leave a comment Go to comments

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 :

show-hidden-files
 


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 :

run_as_administrator

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.

show_all_files

 


Configuration

OS: Windows 7 x86


About the author:
Kosta Hristov (34 Posts)

Hi there ! My name is Kosta Hristov and I currently live in London, England. I've been working as a software engineer for the past 6 years on different mobile, desktop and web IT projects. I started this blog almost one year ago with the idea of helping developers from all around the world in their day to day programming tasks, sharing knowledge on various topics. If you find my articles interesting and you want to know more about me, feel free to contact me via the social links below. ;)




Like the article ? Share it ! ;)


  1. May 29th, 2013 at 23:01 | #1

    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.

  2. May 29th, 2013 at 23:12 | #2

    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

  3. December 6th, 2013 at 12:52 | #3

    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.

  4. April 24th, 2014 at 04:39 | #4

    @James

    Thanks for the suggestion James. Worked for me!

  5. J
    September 18th, 2014 at 22:18 | #5

    Thanks James.. I was struggling with that for a couple days and that worked perfectly.

  1. No trackbacks yet.

Current month ye@r day *


Copyright © Developing the future 2013. Licensed under the CC> BY-NC-ND 3.0 Creative Commons license.       
Audi R8 wallpapers Sony Xperia Z4 Tablet WiFi