Edit hosts file in Windows 7 & Windows Vista

WE RECOMMEND: Fix Windows Errors and Improve Windows Performance

If you're new here, you may want to subscribe to Windows Reference RSS feed Thanks for visiting!

This may sound silly suggestion to even post on Windows Reference but will help avoid some annoyance with Windows Vista and Windows 7. The host file is the one where one enters hostname and IP Address pair manually as against being served by a Name server (ex: DNS). As always the “host” file is under C:\windows\system32\drivers\etc\ or %systemroot%\system32\drivers\etc\ and hence cannot be edited by normal users.

To edit the host file,

Click Start – search for “Notepad“, right-click and select “Run as Administrator“. This should launch notepad with elevated privileges. Now, open the host file from the File menu, edit and save.

This should help!!!

  • Share/Bookmark

Did you enjoy this post? Why not leave a comment below and continue the conversation, or subscribe to my feed and get articles like this delivered automatically each day to your feed reader.

Trackbacks & Pingbacks

No trackbacks/pingbacks yet.

Comments

This help saved some of my time.

When I have logged in to Windows as Administrator, then why there should be a separate process like ‘Run as Administrator’? Is it a bug, or something to do with the security?

Your tip was the ONLY one that even came close to working!

Thanks

You’ve bypassed my reason for refusing to use Windows 7! Usually, I drill down to the file and click on it to open / edit.

When it refuses to save, I get caught up in trying to edit folder permissions. Eventually, I say “stuff this for a joke” and revert to XP.

Of course, I still think it’s a pretty STUPID setup. I have Admin rights- I should be able to do anything I want!

I have no etc folder in C:\windows\system32\drivers\ WHY

Just wanted to say ‘Thanks’ for this. :) I now know how to edit the HOSTS file in Windows 7! WOOT!

I just used this to change my hosts file, under Windows 7 – but it seems that W7 is not using the hosts file.

Why? How to fix??

It worked! Thanks for this, it really helped me a lot!

Didn’t work for me! – In Win7, running Notepad as admin it still opens the hosts file as a sample, and will only allow me to edit the sample not the real hosts file…

I have some very old applications that wont work if I cant edit this – Really need the help here! :)

Hopefully someone found a working solution!

Thx!

Peter: Give it another go. I’ve just verified that this definitely works with Win 7 RTM. Open Notepad > File-Open… > Drill down to the Hosts file > edit it > save it > done.

Windows 7 use is an other hosts file
C:\Windows\winsxs\amd64_microsoft-windows-w..nfrastructure-other_31bf3856ad364e35_6.1.7100.0_none_d196965304ce3de

I got there by copying this %systemroot%\system32\drivers\etc\
into the file name entry, takes you right to it.

thanks, it’s useful

It works for me,when I opened Notepad as “Administrator” and then open the host file from C:\Windows\System32\drivers\etc\hosts. After you make the changes then save it,it should works well.

Good Luck

Thanks a lot. This saved my life.!!!!!!!!!!!

Thanks dude. Love your work.

yeah so after fiddeling with this in windows 7 and having sum issues with actually saving the file as a host and not a .txt file. i finally figured it out.

The notepad must be run as administrator and you must go to the properties of the host file and uncheck read only. once read only is unchecked you can modify and save the host file.

When you save it scroll down and save as “all types” or your hosts file will be saved as txt. file. it will tell you that file already exists and ” do you want to replace hosts with this file” Click ok.

It is a wise choice to actually save a backup copy of your original hosts file just in case you mess up some how. ya never know?

Now everything works fine. I blocked a ton of bad sites i was having problems with. Thanks for the tut and info. Much appreciated . =]

Thanks a lot man. this really helped me :) .People like you are the one who encourage me in Internet world .

Helped me plenty! Thanks!

Hi – I’m runnign windows 7 and have follwed all the instructions. Even when using ultraedit to open the hosts file, the modifications are there and it is saved properly. I flush the dns and restart even and the entries aren’t resolving.

grrrr.

Thank you for the information. I would never have figured out how to give the notepad administrative power on my own.

Hi, thx for the hint… it surely saved me much time frickeling around, shouting at ms and my pc ;o)

Thx a lot!

THANKS A LOT! Sad that actually we “have” admin rights and can´t do everything we like. But who cares, now I have it done! thanks again

Got stuck editing the hosts file too. Ran notepad as administrator as you said and it solved the problem.

Great tip! Worked smoothly!

thanks will try it soon :)

Cheers,

I needed to change the localhost to test my website. Even with the advice I had a bit of trouble. In the end I had to right click “host” go to properties-> security and change the permissions for that folder. That is after doing all the things listed above.

Thanks for this post!

This one’s very helpful I must say, to the point that it feels like a crime to just ignore this page without any comment.

I really need to edit the hosts file to test the website I have created for my client, so this topic is very well appreciated.

I am with those people who are confused and irritated with this kind of setup, because admin users should have admin rights automatically. If there’s a need for admin to limit the usage rights of others who uses the computer, then the rights will be set in the control panel. I don’t really think this (running programs as administrator) is necessary,especially if there’s only one user of the computer (like in my case). Hope this concern already reached Microsoft.

Guess I’ll still use Linux, I still find Microsoft sucks.

Thanks James. After unchecking read only it finally worked

Thanks! it works properly

Maybe You Know to fix my situation I have problem
with edithing this file,
i got the messege “this file is set to read-only”
im using win 7 64 bit tnx for the help

you r the man!

For me it worked after I went to “Properties” and edited the “Permissions for…” my user by going to “Advanced”-> “Change Permissions” button -> Select your username -> Edit -> Select Apply All (if you wish)-> Apply button -> OK

…something like that.

I LOOOOOVE YOUUUUU!!!!!!

I mean it!! Thank youvery much!!!!

Glad I found your post, spent the afternoon struggling with this. You would think MS would put this in the Help file. Thanks again.

i made some changes to mine and it stuffed up WIN 7 BETA
forgot to back up needed to uninstall modem delete network connection n reinstall it really sucks when you stuff your internet up as you have no internet to find a fix

is there a different way to do this eg program that will fake it temporarily

Guys the best way to edit your Host files under win7 is:
First locate you Notepad
Right click on it (dont open it yet)and choose Run As Administrator then confirm it whatever pops out
Click on the File then Open, locate the host file which is normally C:/windows/system32/drivers/etc and click on your host file…edit it or paste something then just click File and Save…thats it ,all Done….but if you still cant save it then make sure that Host file is not In Read Only mode by going to properties of it an untick if necessary The Read Only button.

The sure way of editing a hosts file is simple (for whom it didnt work with elevated privileges). Restart in “SafeMode’ and edit and everything works just fine. Tried and many systems and works flawlessly :)
Cheers

doesnt work out for me.
came out with strange message, even running notepad++ with administrator rights

I was easy to estimate. Thank you.

LOL, its funny watching windows users complain about how hard it is to use windows… Got Linux? I can do what ever I want with my system, can you? LOL

Thanks for this, needed it when installing a local version of BuddyPress.

Millie grazie!

why dont u try to open hosts file properties and just untick the box which says READ ONLY !!!!Its so simple guys..cheers

thank you so much … was breaking my head over it

Every time I try this I update the file and go to save and it only lets me save it as a .txt file even if I select All File. Is there a certain file ext. I need to use when saving?

Edited hosts by changing the properties of the file then just right-click->Open->chose notepad to be used, then after editing just hit Ctrl+S and voila! done.

But tested with Google Chrome, IE5-IE8, Safari, Opera (latest), Firefox 3.6, Avast browsers – none of them seem to even read it.

Windows itself reads it though for other apps that try to go online.

Weird… Any solutions for browsers?

UPDATE: Edited the hosts file here: C:\Windows\winsxs\amd64_microsoft-windows-w..nfrastructure-other_31bf3856ad364e35_6.1.7100.0_none_d196965304ce3de

Well done hades!!!

And it all worked! Had to right-click->”Take owndership” even though I was the admin. Then it became fully editable :) Now all the browsers resolve them hosts as they should!

Thank so much !!

your tip definitely isn’t silly, it’s only easy once you know how.

thanks;)

I’ve been trying to hours to run Notepad as an admin and it still saves the stupid file as a text document. this is driving me insane.

your are god! thanks!

Thanks for this. You made my day! :)

yeah i also try different step.. like creating shortcut in note pad to host file and run as administrator..same problem i got.. i did changed host file and save..but another hosts file appear in a different property.. i check the original file nothing has changed..

ok!!!! finally i figure it out!!! heres what i did and it works great!! just go to hosts file right click property and uncheck readonly , then open note pad run as administrator and edit host file and save!! i did that i my cs4 after generating key. close the cs4 and do the editting in hosts file,, then after, dont forget to check again the read only file option.. i reffer to disconnect the enternet before doing it.. thats all enjoy!!!

Yesss it worked!!! Thanks so much!!!

I have seen the comments on where the Host files are in Windows 7. Is there a simple way to locate them ? Dimon provides details for an AMD system – but I can’t find an equivalent folder in my Intel based system. Any thoughts welcomed.

Thanks so much!

Worked for me.
Thanks.

run netstat from cmd to check tcp connections once edit is done

anything 127.0.0.1 is your local address that you can assign bad websites DNS resolution to.

As a side note: spybot Search and Destroy lists all the bad websites under http://www.007guard.com with the address 127.0.0.1

So if you see it when you run netstat dont panic!

Here you can read about why update of the file hosts sometimes needs special attention.

“Because of its central role in local host resolution, the hosts file represents an attack vector for malicious software. The file can be hijacked, for example, by adware, computer viruses, trojan horse software, and may be modified to redirect traffic from an intended destination to sites hosting content that may be offensive or intrusive to the user or the user’s computer system.The widespread worm Mydoom.B blocked users from visiting sites regarding computer security and antivirus software and also affected users’ ability to access the Windows Update website. Administrators can set the file permissions of the hosts file to read-only as a means to help defend against malicious redirects caused by malicious software editing the hosts file when casual users without permissions use the computer.”

Microsoft ROCKS!!! I feel so bad when people say bad things about microsoft! Apple looks like a toy, and Microsoft is the best!

Give Microsoft a break! They’re awesome and make great products.

Thanks! Such easy and such effectively! :)

im trying to delete security tool from my cpu using malwarebytes and changing my host name to default but how do i change it to default does anyone know?

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required)