Encountering an error while attempting to edit the LMHOSTS or HOSTS file in Microsoft Windows 11 is a common issue. You may come across one of the following messages:
- “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.”
These errors usually indicate a lack of proper permissions to access the file. Fortunately, resolving this problem is relatively straightforward. Follow these steps to overcome the issue:
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 highlighted in the “Group or user names” area, select the “Allow” check for “Full control“. Select “OK” when you’re ready.
Congratulations! You now have access to edit the file, and you won’t receive any more “Access Denied” messages when attempting to work with it.
If you still encounter issues editing these files, it’s advisable to investigate whether malware or viruses are affecting your computer. You can try running a MalwareBytes scan to identify and resolve any potential threats.