Edit hosts file in Windows 7 & Windows Vista
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!!!
Sponsored:

Incoming search terms:
- windows 7 hosts file (1383)
- hosts file windows 7 (952)
- host file windows 7 (692)
- windows 7 host file (685)
- windows hosts file (521)
- windows host file (346)
- hosts windows 7 (324)
- windows 7 hosts (302)
- host file in windows 7 (262)
- edit hosts file (211)
Trackbacks & Pingbacks
No trackbacks/pingbacks yet.
Comments
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>






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;)
better solution:
http://support.microsoft.com/kb/923947
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?
Thanks, man! It really helped!
Thanks you totally rock
You saved my day
!!!
I was about to loose my mind… A million THANKS!!!
Thanks a lot! Your way to solve this problem is the best and fastest!
+5 respect bonus points from me
I wish I had found your tip several hours ago…it would have saved me LOADS of frustration. Thank you. It worked wonderfully and I was done in minutes.
MANY MANY THANKS !!! Your idea it works! Great job man!
I’ve been using HostMan up until Vista and Windows 7, as i hated making entries into the windows host file. The User Account Controls was a pain to deal with … extra screens when i simply just want to make a simple change to a text file. Anybody out there have any suggestions on Alternatives to HostMan, or alternative methods for maybe dynamically managing dns entries locally?
This still does not work for me, when I try to overwrite the hosts file it tells me that this file is read only.
Thanks…it does work on WIN 7
Thanks mate,
I changed to hosts.txt.
What’s fomat of this file ?
U have to open this path for administrator rights opened noteped to work:
C:\Windows\System32\drivers\etc\hosts
fking stupid micro&$oft
there’s no format, no extension, just like this:
hosts
if you changed it, change it back to this.
just what I needed thanks!
Thanks, very helpful
Great it just saved my mods. Great man Thanks a lot
Please for the love of all things sacred…
- it is read only, as people keep frickin saying! just uncheck the read-only box in properties, as people keep frickin saying!
- even if you are administrator, just rightclick > run as admin on notepad, as people keep frickin saying!
- just file > save when done editing, as people keep frickin saying!
All people have to do is read the article / comments, and the info is right there, but they keep asking over and over and over…..
Thank you very much for this fix it helped me out alot I booked marked this page for sure, I have tried everything to get flashplayer games e.g. facebook/farmville to work for three months or better, highly recomend this site to anyone and again thanks, Tony
thanks..saved some time
Good One.. Thanks for sharing..
You just helped me there!!
Nitin
thank you, this has been running me made, it’s completely counterintuitive.
Wait once I edit my host file correctly, how do I save it as a file not a (.txt) file?
this was a waste of my time. The same message comes up every time. I might as well keep trying it the obvious way that doesn’t work.
Hey man.. This helped me a lot! that was really simple and from month I was trying to edit it but cudnt do it..
THANX A LOT MAN
if u have administrator privilages, there is an another way, save as text file, then remove .txt extension, then over-write existing host file. u r done.
To save the file you have to:
1. Select Save As
2. Change the filetypes setting to All Files
3. Make sure your filename is hosts
4. Click Save
Many THANKS, Winsockfix!!! This was exactly what I needed. I love it when searching for solutions to problems is so easy and I find it first try.
Thanks for the tip, its been a while since I had to edit my host file, anyway – Right to the point, thanks.
ok, ive followed all the suggestions given so far, and i think its going ok but when i try to save it im told i cant coz its open or being used by another program? ive only got AVG running as far as i know, so why is that using it? if not why does it say this? cheers!
Thanks!!!
Simple and easy!
If Windows 7 is ignoring your Hosts file, this is what worked for me: Solution to Ignored Windows 7 Hosts File. Good luck!
I’m using win7 64bit.
I have found the “hosts” but I can not edit it.
I’m administrator, when I want to change the permission as an administrator, but I cant!!!
IT’s owner is : system, and I cant modify the permission as an administrator neither…
So what the f*** should I do?
I hate win_DOS!
@ssss – holy wow… did you not read the many, many entries above that tell you that when you start Notepad, you have to “Run as administrator”, even if you are already an administrator-class user?? Right-click the Notepad icon, you’ll see the option there.
I’m using win7 pro 64bit running notepad pad as admin as well, but it won’t even open the host file, everytime I go o open it in notepad as the admin it opens the sample version only, I’ve also tried to load windows in safemode to no avail either trying to go to safe mode just takes me to startup repair, tatting to feet flustered, any other suggestions aside from whats already been listed
when i open the hosts file, inside it says ‘This is a sample HOSTS file used by Microsoft TCP/IP for Windows.’ is it meant to say this? or am I doing something wrong? I opened the Hosts file in C:\Windows\System32\drivers\etc and in C:\Windows\winsxs\x86_microsoft-windows-w..nfrastructure-other_31bf3856ad364e35_6.1.7600.16385_none_045b589158ae90da help anyone?
Windows 7 Ultimate –
1 – Located Notepad
2 – chose run as administrator
3 – pasted location of hosts file which is impossible to type by hand since it is a huge path on 64 bit systems (NOT windows/system32 on 64 bit)
4 – edited hosts file as needed
5 – SAVE – logged in as admin and opened Notepad as admin – still I do not have permission to save this file.
I’ve worked on Linux and Windows since mid 90s and have always been able to edit the hosts file without problem, until now.
Way to go MS – another insanely stupid idea – let’s take away file editing privileges from logged in Administrators!
I also am using Win7x64 and in order to finally make changes to and save my host file I needed to go to properties of the folder AND the file and take ownership of them. What a PITA.
Under Security, Advanced, Owner both the folder and the file were owned bt SYSTEM – changing to Admin/MyName produced a sequence of errors, but eventually it changed – again – what a PITA.
Finally achieved my ends, but now I cannot revert the ownerships to SYSTEM – I bloody well hope that doesn’t screw my system up.
Thx MS for making this task so nearly impossible.
Thanks for the question and answer! I was wondering how come I couldn’t edit it.
Great!So easy and save my time!!!Thanks a lot!!!
thanks mate.. It works charm
Thanks a lot! Very good instructions.
We have two boxes with Win7 Ultimate. The ‘Notepad run as administrator, open the hosts file, modify, and save’ trick used to work at least as recent as July 2010. It doesn’t work any longer, and I don’t want to take ownership from system. A windows update problem perhaps?
What does work for me is:
-Run Notepad as administrator
-Open the hosts file and modify as needed
-Save the hosts file under a different name
-Use explorer or cmd to change the name of the original hosts file
-Rename the newly created file to hosts
I don’t know what has changed and why the simple solution no longer works for our environment.
Thanks for posting this. Saved me a lot of time!!
Hi
solution for those who cannot edit hosts file with above mentioned solutions. (even in safe mode cant do a thing, eveything is protected, even when iam admistrator)i have w7 64. my hosts file is under windows/winsxs/amd64 etc ( you know where).
it took me maybe 1,5 hour to find it. so ill share it with you.
http://www.sevenforums.com/tutorials/1911-take-ownership-shortcut.html?ltr=T
go there and download a small zip file with reg files Add_Take_Ownership and Remove_Take_Ownership.
Thats it. just run Add_Take_Ownership.reg then richt click on hosts, take ownership a edit. you can then use Remove_Take_Ownership.reg a everything is back as it was
Hope to save your time a nerves
Thanks for people with brain to help us with out it
Nice, works fine here! Thank you!
Thanks much, I anticipate this will work!
Thank you Zia Shaikh for a solution that worked.
Never have I seen such a resounding apreciation!
To which I add ‘Thanks dude!’
!!!!!!! thank you !!!!!
Mike,
Transilvania.
just wants to say this worked ! thanks a lot
it took me almost an hour to figure out why it wasnt working. check your antivirus to make sure its not locking the file. i know avira does.
Thanks a lot for the tip!!!
Thanks. Works like a charm, together with ‘block content’ in Opera. Advertising is fine as long as we look it up voluntarily. The right-in-your-face attitude kills the beauty of the internet.
Perfect — thank you!
on Windows 7 , there is hidden directory etc\ in C:\Windows\system32\drivers\ … in this directory you will find hosts file … I can only edit this file logged as administrator ..
hope it helps
I forget .. I can also see that hidden \etc\ folder only as Administrator … logged as user from admin group, I can’t see that folder .. So try to do all changes as Administrator, and you will win over Windows ..
Finally, I got the way to edit host file in Win7. After reading all the comments all over again, maybe I just report one way.
1. Find your host file, right-click it, and click on ‘Properties’.
2. If it says ‘Read-Only’, uncheck it and apply.
3. Open your Notepad by right-click it, ‘Run As Administrator’.
4. With the opened Notepad, File>Open>….find the host file.
5. Edit and save..
then You good to go.
worked like a charm…great thanks
thank youuuuuu!!!!!!
p.S. LAST GUY has the right way . Dont forget to put back your host file in read only! Because some virus can tamper with it if its not in read only and you can even hide it, so your kids or other person cant tamper with it.
thanks it really worked
UPDATE: Edited the hosts file here: C:\Windows\winsxs\amd64_microsoft-windows-w..nfrastructure-other_31bf3856ad364e35_6.1.7100.0_none_d196965304ce3de
Thanks you are a life saver <3
Thanks I need This tutorial
I’m using Windows 7 Home Premium 64-bit.
The only host file(s) I’ve found in either directory,
C:\Windows\System32\drivers\etc OR
C:\Windows\winsxs\amd64_microsoft-windows-w..nfrastructure-other_31bf3856ad364e35_6.1.7100.0_none_d196965304ce3de
are sample files!? My firewall is ZoneAlarm and, at the beginning (after installing Windows, then ZA) I had ZA lock the host file (I assume ZA ‘knew’ where the host file was/is) – - could that be why there are no other host file(s) other than the sample ones?
Thanks in advance!
1. Click Start, click All Programs, click Accessories, right-click Notepad, and then click Run as administrator.If you are prompted for an administrator password or for a confirmation, type the password, or click Allow or Yes.
2. Open the Hosts file or the Lmhosts file, make the necessary changes, and click Save on the File menu.
I tried these steps, butw hen i go to etc then try and access my host file nothing is tehre like it no longer exists, how can i acces sthis?
Thanks … it works perfectly
Well just to clarify the situation. I’m running vista home premium 64bit and all I had to do to edit and save the hosts file was as follows:
1. Find the hosts file ie. c\windows\sytem32\drivers\etc and opend the hosts file with notepad. Ctrl+A to select all the text then Ctrl+C to copy all the text to the clip board then close the hosts file. You haven’t made any changes at this stage so you won’t be prompted to save the file.
2. Right click on your notepad programme and choose run as administrator.
3. When note pad opens in admin mode you then copy the hosts file into notepad ie Ctrl+v to paste then Ctrl+S to save. The window should open giving you the opportunity to save as a .txt file but click on the down arrow and choose “all file types” then choose save in the same directory as the hosts file.
4. You will be told that the file already exists and would you like to replace it with the one that you have copied and presumably edited, choose yes and your done!!
Hope this helps.
Thanks for the hint.
Worked great! thanks for the tip. for those who cant see the files select “all File Types” where it reads .txt text files.
Thanks again!!
thnxxxxxxxxxxxxxxx for help
i cant edit my host file…it says “Compatibility modes cannot be set on this program because it is a part of this version of Windows”
i am using win7 Pro SP1
plz hlp…
THANK YOU! THANK YOU! THANK YOU!
i have tried everything but it still never works i need help please i am going crazy
actually the comment Jeffrey Yong posted a couple messages back actually works.
Thanks a lot you just made my day
If you’ve made this far down and still cant get it then let me tell you what i did:
1 – OPEN START MENU
2- ALL PROGRAMS
3- ACCESSORIES
4- RIGHT-CLICK ON NOTEPAD
5- SELECT RUN AS ADMINISTRATOR
6- WHEN NOTEPAD IS OPEN, SELECT FILE MENU
7- SELECT OPEN
8- NAVIGATE TO HOSTS – C: WINDOWS/SYSTEMS32/DRIVERS/ETC
9- ADD YOUR ENTERIES TO HOSTS FILE
10- SELECT FILE MENU THEN SAVE
11- JOB DONE
honestly, it is very easy, once you’ve done it you’ll wonder what the hell you’ve been doing all this time.
thankss dude…
save my work today
Thanks Great Help
brilliant!
Follow the instructions *exactly* as Akshay wrote. Also, thanks, everyone.
thanks bro
Thanks.
Just copy “%systemroot%\system32\drivers\etc\hosts” into the open box and click open. Make the desired changes. Then save.
very nice. thanks for sharing!
Thanks for the tip! This saved me lots of time and stopped me from swearing off Windows once again.
I edite host file but not work
like
http://www.facebook.com
is not work
i need this site block this site but noting
It worked for me! Had to test working of newly transferred wordpress blog and couldn’t edit host file. A google search rendered this article and I am so glad that it did
i need to redirect facebook to google
i tried so much but didnt work
i am using win 7
thnx
1. Find the hosts file ie. c\windows\sytem32\drivers\etc and opend the hosts file with notepad. Ctrl+A to select all the text then Ctrl+C to copy all the text to the clip board then close the hosts file. You haven’t made any changes at this stage so you won’t be prompted to save the file.
2. Right click on your notepad programme and choose run as administrator.
3. When note pad opens in admin mode you then copy the hosts file into notepad ie Ctrl+v to paste then Ctrl+S to save. The window should open giving you the opportunity to save as a .txt file but click on the down arrow and choose “all file types” then choose save in the same directory as the hosts file.
4. You will be told that the file already exists and would you like to replace it with the one that you have copied and presumably edited, choose yes and A MESSAGE SAYS: THE PROCESS CANNOT ACCESS THE FILE BECAUSE IT IS BEING USED BY ANOTHER PROCESS!!!!
using windows 7 64-bit
please help
Thank you! It solved my problem in one try. Once again, thank you.
THIS TOTALLY HELPED OUT !! A BIG THANKS !!
REGARDS
Ah, I forgot to check the .txt extension on my hosts file. I had one and that is why is wasn’t working. Now, I am all set. Thx for the post! –Richard
hiiiiiiiiiiiiiiiiiiiiiii,
a big thanks to u
I do it this way:
1. Copy hosts file to your desktop,
2. edit it with Notepad++ and just click Save
3. replace the old one in etc folder with the new one from your desktop.
Thanks alot
I tried everything and nothing until I take dhiraj advice THANKS man you rock
Obviously, it is NOT as easy as AKSHAY’s post, or people wouldn’t be posting for more help over and over, so WHY do you keep repeating how easy it is? Please it is NOT that easy, at least not with AMD, on my win 7 it does not even have the file that was posted above! The only hosts file says, “sample only” >> downloading take ownership app, any other advice?
thanks! its worked
This helped me save me time and is perfect.
Thank you so much for the video instuction on how to edit the host file on vista. It made it so easy for me to get into my host file and delete all the IP’s that has been preventing me from signing into my hotmail account. What a great relief to finally get this over with after about 10 grueling days of less sleep and stress trying to figure out what is a host file, how to find it and edit it e.t.c. I am a computer illiterate, so this was a great learning experience for me despite all the troubles i went through, it is worth it. Thanks alot and God bless you.
Great !!!
thamk u
Editing (and implementing) my hosts file only leads me to believe my DNS is hosed. Thanks for the information.
i cannot configure it, i did it but i m not sure it is right
I’m stuck with the most stupid problem ever !
the original hosts file won’t let me unmarke “read only” an error window pops up saying:
an error occurred applying attributes to the file :
c:\windows\system32\drivers\etc\hosts
access denied
Now , I made a copy of the hosts file and edited it with your method just fine
( the copy wasn’t marked “read only” to begin with )
but I can’t remove , rename , or replace the original with the edited copy
what to do ?
thank you very much!! ><
when i try to run notepad as administrator i getting the error -unable to logon, logon failure.uer account restriction.possible reasons are blank passwords not allowed, logon hour retriction has been ennforced. why! please help me
I have successfully edited my host file, but every time I log in from a different wireless server my changes are lost, and I have to edit it over and over again. Why is that happening and how can I prevent it?
That Run as Notepad option also not worked for me ,In Safe Mode We can able to edit the host file ,Checked it was working for me
thank you very much
i weast my half day time to solve the problem.
finally reading one of these comments, on hosts right click property and untick read only. problem solved.
This worked a treat. Thanks for posting as I could not find this file anywhere!
Thank you
I always forget admin privileges required to edit these files.
Thanx…!
Hi I had the same problem but I beat it by running pc in safe mode with administrator rights and just copy and paste over old host file…Before I kept getting the prompt other programs are using this file…
Running notepad as administrator worked for me as far as saving the hosts file goes, but win 7 would still not resolve anything out of the hosts file.
That is Until I connected one network card on the pc to a network, then it started reading the hosts file all of a sudden. So looks like windows 7 needs an Active network card before it will start looking in the hosts file.
I was at the point of dumping a project when I found this, thanks it helped.
Thanks for the info. I’ve never had to worry about this file type until today- thanks for the help.
Another way to do this is to right click the hosts file and select properties. Then untick read only. Then it can be opened, edited and saved, providing the file is not in use. If it is in use, you can save to your desktop and then delete the hosts file, replacing it with the one you saved to your desktop.
I agree with other commenter’s, this is entirely insane. I am the admin of the PC, why can’t I change the hosts file as I could with XP? Microsoft, please quit assuming we are all idiots.
Just goto properties and in security tab add “everyone” and allow al permissions and save settings…u r done
Thank you! It is odd to consider that there might be solutions to _many_ MS Win problems.
This worked better than I expected Many Thanks.
I have made a huge mistake by rightclicking on a file called “HOSTNAME” in Windows 7 in C:\windows\system32\HOSTNAME and then selecting open with note pad.
Now all applications such as Google chrome, Skype, etc are not working and when I click on them notepad opens with some weird computer language!! Any ideas?
Really must read page
When I opened NotePad as indicated (in Windows 7 Home Premium SP1), and navigated to …/drivers/etc, at first I did not see any files. Then, Duh, I saw that the filetype was defaulted to ‘.TXT’. Changed that to ‘All Files (*.*)’ and whereupon the hosts file showed up. I added my subdomains for localhost, did File > Save, and immediately WampServer was happy with api.localhost and the others I had added. It is important to start NotePad with the right click > Run as Admin option; the rest (other than selecting ‘All (*.)’ extensions) was business as usual. Thanks!
Thank you.
Your ROCK man!
You should be the CIO of some MS branch or something…
Great tip, thank you.
@amit – I wouldn’t make your hosts file available to everyone; it’s a common target for viruses and other malware. They can replace a link to (say) your internet bank with one to their own copy site, and the URL in the browser would look fine; you’d know nothing until your payment started bouncing.
Those who commented about it being a “SAMPLE” file- yes, until you add stuff, it only has one entry, which equates “localhost” to 127.0.0.1.
What I’ve done is to add a shortcut that contains
“notepad c:\windows\system32\drivers\etc\hosts” as the target (without the quotes).
When I need to edit it, I right-click on the shortcut and select “run as administrator” – even if you’re already logged in as admin, you need this “elevation” to trigger the UAC challenge, which scripted tasks can’t pass.
Oh, and those who have a fancy path on X64 system – that’s directed via winsxs system (Windows side-by-side) which allows 32-bit and 64-bit to co-exist; if you resolve the path, it’s actually pointing to the same file as the one in System32.
look, ive been on the admin profile on my computer and my normal one. i am the ONLY USER to this computer and i try everything ive been at this for 46 hours straight. EVERY time i go to save it it tells me my hosts file is set to ready only. so when i go to change it it wont let me saying i need to be an adin.
i went on to the REAL admin profile (witch is a hidden profile on your computer) and it STILL wont let me change it from a ready only file. i NEED HELP ASAP PLEASE!!!!!!!!!!!!
ill love you forevers!
For you Notepad++ users the “Run As” method won’t work. For some reason when you browse to the C:\Windows\system32\drivers folder the ‘etc’ folder is not displayed and thus you can’t get to the hosts file. Weird. And if you start NotePad++ in Run As mode and then try to open hosts from Windows explorer the file does not open. Looks like running standard Notepad in ‘Run As Admin’ mode is the only way to edit.
you nailed it perfectly, thank you so much!!
copy hosts-file to desktop from “%systemroot%\system32\drivers\etc”.
edit hosts-file on desktop and add these lines before save:
#pass WGA-check in windows xp pro corp.
127.0.0.1 mpa.one.microsoft.com
# Pass OGA-check for Office 2007
127.0.0.1 sls.microsoft.com
# not sure yet
127.0.0.1 activation.microsoft.com
now copy hosts-file from desktop to:
“%systemroot%\system32\drivers\etc”
(%systemroot% = “c:\windows” most of the times)
admin-rights required !!!
i tried this but when i open from notepad menu and goes to the location of my host file i finds nothing.. but if i go their directly via my computer the files are there..
HELP..
thank you for your help with this. it worked great
THANKS A LOT!!! It did the trick. Been thinking ages why I can’t edit ‘HOSTS’ and your tip worked.
thanks you very much.its worked.
Good one. Saved my time ! Worked as said. Great !
Thanks for the fix btw. Actually worked! But I am curious why this is still an issue with Google, considering the original post was back in early 2009?
thanks you very very much.its worked.
thanks man… internet rocks!
I want to say that if you have any anti-virus installed in computer. It may lock host file cause that you can’t change host file even with administrator permision. So disable anti-virus then do like this article.
god bless u thax sooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo mutch
I have tried but host file is nowhere to be found. I am running as administrator. It didn’t work so I disabled antivirus. Still cant find the file. I filtered it to all files instead of text files.
I have found hostname file and ihost but these are exe files and when opened in notepad there obviously scrambled code. Can anyone help? Thanks.
So I can’t run my ACTUAL host file, because it continually shows up as a sample host no matter what I do. I’m running as Admin, I tried to open the file directly from notepad and I’ve read EVERY SINGLE COMMENT HERE and I’m still having the problem! How the heck do I get it to quit showing me the stupid sample file?! Please help, without my Google websites I don’t have access to my main email and my important documents ): also I’m running Chrome, dunno if that has anything to do with any of this.
The problem I was having why it wasn’t working was because I had my antivirus enabled. If you are still having problems, try disabling your antivirus.
Simple and well explained..to the point. Well done!
Awesome & Superb Trick. It helped me a lot. Thank you.
I swear thanks you sooooooooo much!
the reason you have to run as the administrator Is because with windows vista and 7 your account is not truly the admin its a security thing but can easily be enabled just do a quick google search on how to enable the hidden administrator account . All thought its not recommended as I said security reasons good to know how to enable it thought if you ever get hit with a bad virus they shouldn’t effect the admin account since its not active……. The more you kno
Glad I found your post, spent the afternoon struggling with this. You would think MS would put this in the Help file. Thanks again.
nice tips, thanks alot
THANKS ALOT
GREAT HELP GOD BLESS YOU
Worked. Thanks!
A word to a wise
thanks man
I am at my wit’s end – my hosts file is infected somehow (igoogle and random ad servers will redirect me to adware sites), but every single virus scan i’ve tried comes up totally clean and my only option appears to be editing the hosts file. Hijackthis is utterly useless, as the file has been blocked as read-only – and here comes the infuriating part.
The problem is, no matter what I do, I can’t disable the hidden and read-only status of the file! Every time I uncheck “read only” in the etc folder then hit apply, I get an error window – “You will need administrator permission to change these attributes. Click Continue to complete this operation”. I *am* the administrator, and click continue (with the little admin logo next to it), but this does absolutely nothing and the folder/files still remain read-only. I can open the file in notepad and delete the bad entries, but I can’t actually save it because (surprise) it’s read-only.
Not like I can fix it right now anyway and i’m not sure if it’s relevant, but here are the bad entries in question:
67.215.245.19 http://www.google-analytics.com.
67.215.245.19 ad-emea.doubleclick.net.
67.215.245.19 http://www.statcounter.com.
108.163.215.51 http://www.google-analytics.com.
108.163.215.51 ad-emea.doubleclick.net.
108.163.215.51 http://www.statcounter.com.
Thank you very much
mosasart.tk
Thanks a million! Such a great tip!
Those of who failed to modify the hosts file, try and take ownership of the file (Properties >> Security >> Advanced >> Owner >> Edit) or see the microsoft support site on how to change ownership. Once you own the file, give yourself or your group write permissions, and then modify the file.
thanks alot…..now i get how to edit hosts file
keep learn people//
Tanx a tonne 4 de post it’s actually working..yuppie finally i done it..:)
Thanks so much for posting this.
YOU HELPED SO MUCH
screw all the others tips i read and most of all screw you windows permissions!!
check antivirus, maybe antivirus or other program block u from changing ur host file like mine..i m using antivir antivirus, it block me to change my hosts file..
The very first answer in this posting answers the question how to edit the hosts file with just one minor addition: When the message says “No items match your search” You need to simply Change file type from .txt to All Files (“.”)
After wasting a few hours, I found that this combination works every time, and only takes a few minutes.
There are many helpful comments in this posting, including the hint to change file type. Thanks for all of your help.
Here is the solution which works, with minor adjustments to the great work previously proposed by by winsockfix and badbob117.
First check that the ‘hosts’ file exists in the path:
C:\WINDOWS\SYSTEM32\drivers\etc\hosts
Alternatively, to get there more quickly, you can ‘search programs and files’ for %systemroot%\system32\drivers\etc\
If you cannot see any files within the ‘etc’ folder, you may get a message such as ‘No items match your search.’ Don’t panic, Simply change the file type to All Files “.”
Even if the ‘hosts’ file does not exist, don’t worry. Just get to the ‘etc’ folder because you can save a ‘hosts’ file, which you create, in that folder.
Usually, the ‘hosts’ file will already exist.
If it already exists, within ‘START,’ search programs and files for ‘Notepad,’ then RIGHT CLICK and choose ‘Run as administrator’
Now navigate to the ‘hosts’ file using the path mentioned above.
Open the file and add a new line within the file, where you will enter IP Address and hostname, separated by at least two spaces on the same line.
Save the file. If the resulting file saved is named ‘hosts.txt’, rename it to ‘hosts’
since there should be no extension.
THATS ALL that is required and it truly only takes a few minutes.
You do not need to change the properties of the ‘hosts’ file because you set Notepad to ‘run as administrator’ earlier. < < <
HISTORY and acknowledgments to WINSOCKFIX and BADBOB117
I had experienced frustrations too including messages such as 'An error occurred applying attributes to the file' and 'No items match your search' and many others reported by administrators concerned that full administrative rights had been removed and that they only had 'read access' to the hosts file if they could even find that file.
The original posting by Winsockfix to which there had been 226 comments, many of which express frustration, and even unneccessary suggestions to change file permissions within file properties was the most helpful. There has been much venting about Microsoft and concern that full adminstrative rights have been removed.
All of this is so unneccesary, as I tried many of the suggestions and finally discovered that small adjustments to the original (March 2009) posting by winsockfix worked, using PART of a minor addition proposed by badbob117 in October, 2009.
You helped me so much people!! You are amazing!!