Unable to Save Hosts File on Windows 7, Vista, XP
September 3, 2012 in iPhone How-to & Tutorial by
In general we are able to modify system file
to map an ip address to name. However the default owner of hosts file is system, therefore we need to have administrator privilege to modify file hosts otherwise you will get error like “access to hosts file is denied”.
Access to C:\Windows\system32\drivers\etc\hosts was denied
Cannot create the C:\Windows\system32\drivers\etc\hosts file. Make sure that the path and file name are correct.
Method #1 to modify hosts file on Windows 7 / Windows Vista
Edit the hosts file using notepad with Administrator’s right
1. Open your Notepad or Wordpad with administrator privilege. Click Start → type Notepad.exe in the search box, so that it appears in the program list (or browse to it Start → Accessories → Notepad)
Right-click Notepad.exe and choose Run as Administrator
2. If you prompted by UAC (User Account Control), click Yes OR type in the username with admin privilege and it’s password
3. In your Notepad window, click File → Open then browse to
select All Files*.*, then open and modify hosts file
Method #2 to modify hosts file on Windows 7 / Windows Vista
Take ownership of the hosts file and change its permission
- Right click on hosts file and click “Properties”.
- Switch to “Security” tab and click Edit button.
- Click your user name or group name (in this example, my username is Users).
If you don’t see your username or group name on the lists, click Add → Advanced → Find Now → Click Username → OK → OK.
- In Permissions for Users (your windows Username) setting, click Allow on Full control option.
- Click OK → Confirm Yes → OK
- Now you can edit hosts file with notepad as normal without getting denied error message again.