Editing the HOSTS File in Vista

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

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

2 Responses to “Editing the HOSTS File in Vista”

  1. Michael Ageeb

    Well the case isn’t only with the hosts file.

    Windows will require you to explicity login with the machine admin account to be able to edit these kind of system wide configuration files in Windows.

    Same case as the hosts file in Linux you need “sudo vim /etc/hosts” and the sudoers file you can’t just edit it you need to use “sudo visudo”



Leave a Reply

  • (will not be published)