How to Fix Access is Denied While Editing Hosts File

When you attempt to open, save, or edit the hosts file, a system file in Windows 10, you receive the error “Access is denied.”

Select one of the four methods below to fix this error.

Method #1

Start the Notepad app as an administrator.

Press File > Open.

Go to this location – C: > Windows > System32 > drivers > etc.

Choose “All Files” from the list above the “Open” button.

Select the “hosts” file.

Click on the “Open” button.

Notes:

If you are not using Notepad, open the text editor program you are using as an administrator, then open the “hosts” file in it.

If the problem persists, make sure the “hosts” file is not read-only.

Here’s how you can do it:

Right-click on the “hosts” file.

Click on “Properties.”

See “Read-only” in the pop-up.

In the case it is not selected, close the popup, otherwise remove the selection and click “Ok.”

Method #2

Start the Command Prompt as an administrator.

Enter the following command and then press the “Enter” key.

Here is the command: cd c:\windows\system32\drivers\etc

Enter the following command and then press the “Enter” key.

Here is the command: notepad hosts

Note:

In case it doesn’t solve the problem, make sure that the “hosts” file is not read-only. Here’s how you can do it:

Right-click on the “hosts” file.

Click on “Properties.”

See “Read-only” in the pop-up.

If it is not selected, close the popup. Otherwise, remove the selection and press the “Ok” button.

Method #3

Copy the “hosts” file to the desktop.

After saving the file, copy or cut the “hosts” file on your desktop and paste it into the “etc” folder in C: > Windows > System32 > drivers.

In the pop-up, click “Replace the file in the destination.”

Click on “Continue.”

Method #4

Open the elevated Command Prompt.

Enter the following command and press Enter:

net user administrator /active:yes

This command activates the hidden administrator account.

Log into the “Administrator” account that you have activated now.

Access the hosts file.

Once you are done with the file, sign in to your user account and then disable the hidden admin account.

Here is how:

Open the elevated Command Prompt.

Enter this command and press Enter:

net user administrator /active:no

That’s it.

Read:

Default image
Thirumalraj
How To Raj was founded and run by Thirumalraj, an MCA graduate. Since August 2015, he has been blogging on his other blog, Technology Hint. Learn more about How To Raj here.