With their latest Vista (non)operating system, Microsoft has decided in their infinite wisdom that you do not need permission to edit the HOSTS file (and many other system files), telling you instead after an attempted edit that:
“Access to C:\Windows\System32\drivers\etc\hosts was denied.”
There are many reasons you might want to edit the HOSTS file:
- Block browser access to a website;
- Block an application from contacting an update or heartbeat website;
- Block advertisements from specific content providers;
- Mimic a hostname without requiring chnages to DNS;
In my case, this morning, I was trying to run a development version of WordPress on my local computer, but WordPress won’t allow itself to be accessed by visiting http://localhost or http://127.0.0.1.
One Solution of Many
Right-click Notepad, and select the “Run as administrator” option. Now simply open the HOSTS file with Notepad (the file’s still in the C:\Windows\System32\drivers\etc\ folder). This time when you save your changes, there will not be an access-denied message.
Thanks to Michael for pointing out that Linux does the same thing: Just preface the command with “sudo”, as in “sudo vi /etc/hosts“