You might get an error when you try to edit the LMHOSTS or HOSTS file in Microsoft Windows 10 that says one of the following:
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.
This problem is usually related to not having proper rights to the file. To solve this problem, follow these steps.
Allow Access One Time
- Select “Start” > “All Programs” > “Accessories“.
- Right-click on “Notepad” and select “Run as administrator“.
- If you are prompted for an administrator password or for a confirmation, type the password, or select “Allow“.
- Open the Hosts file or the Lmhosts file, make the necessary changes, and then click “Save” on the “File” menu.
Permanently Allow Access
Note: This option is not recommended as it may allow a virus or malware to easily modify the Hosts or Lmhosts file.
- Right-click the Hosts or Lmhosts file and select “Properties“.
- Select “Security“.
- Select the “Edit…” button to edit permissions.
- Select “Add…“.
- Type your username to allow just your account access, or type “EVERYONE” to allow access to anybody. Select “OK” when you’re ready.
- With the account you just added higlighted in the “Group or user names” area, select the “Allow” check for “Full control“. Select “OK” when you’re ready.
Now you should have access to edit the file and no longer receive “Access Denied” messages when attempting to work with it.
If you still cannot edit these files, you may want to look into whether or not you have malware or viruses installed on the computer. Try running a MalwareBytes scan to see if you can clear it up.