Editing the hosts file is a relatively advanced procedure, so are likely to receive some errors like access denied when modifying HOSTS or LMHOSTS file during the process. If you are bothered by the same issue, congratulation! You have come to the right place. In this post on MiniTool Website, you will be enlightened.
Access Denied When Modifying HOSTS or LMHOSTS File
Sometimes, you need to change the hosts files to solve some problems or block a certain website on your computer. The hosts file is stored in the installation directory of your computer and you cannot edit it without authorized privileges. Take it easy, you can fix the access denied when modifying HOSTS or LMHOSTS file error with ease after following the solutions below.
MiniTool ShadowMaker TrialClick to Download100%Clean & Safe
How to Fix Access Denied When Modifying HOSTS or LMHOSTS File on Windows 10/11?
Fix 1: Run Notepad as an Administrator
Before editing the hosts file, you need to run Notepad as an administrator. Here’s how to do it:
Step 1. Type Notepad in the search bar and right-click on Notepad to select Run as administrator.
Step 2. Click on File > Open > locate to C:\Windows\System32\drivers\etc > change Text Documents (*.txt) to All Files > select the hosts file > hit Open.
Step 3. Make the changes you want and save them.
Fix 2: Disable Read-Only for the Hosts File
Once the hosts file is set to read-only, you cannot change or edit it. To fix the access denied when modifying HOSTS or LMHOSTS file error, you might need to remove this attribute manually.
Step 1. Press Win + E to open File Explorer.
Step 2. Navigate to C:\Windows\System32\drivers\etc.
Step 3. Right-click on the hosts file and select Properties from the context menu.
Step 4. Under the General tab, untick the Read-only attribute.
Step 5. Click on Apply & OK to save the changes.
Fix 3: Change the Security Settings for Hosts
To access these files, you need to get special privileges. Once you lack of the privileges, you might encounter access denied when editing hosts file. Here’s how to grant the privileges:
Step 1. Navigate to C:\Windows\System32\drivers\etc in File Explorer.
Step 2. Right-click on the hosts file to choose Properties.
Step 3. Under the Security tab, click on Edit.
Step 4. Now, you can see a list of users and groups. Make sure your user name has full access and control.
Select your user account and tick Full Control.
Step 5. Click on Apply & OK to apply the changes.
Fix 4: Change the Hosts File Location
It is reported that changing the file location also helps to solve access denied when modifying HOSTS OR LMHOSTS file.
Step 1. Navigate to C:\Windows\System32\drivers\etc in File Explorer.
Step 2. Locate the hosts file, right-click on it to choose Cut > paste the copied file on your Desktop.
Step 3. Open the hosts file on your Desktop > make necessary changes on it > press Ctrl + S to save the changes you made.
Step 4. Copy & paste the changes hosts file to its original location.
Bottom Line
In this guide, we have showed how to fix access denied when modifying HOSTS or LMHOSTS file in 4 ways. Also, don’t forget to secure your data with a piece of reliable backup software – MiniTool ShadowMaker.