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 aren’t using Notepad, open the text editor program you are using as an administrator and open the “hosts” file.

If the problem persists, ensure 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 popup.

If it isn’t 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:

If it doesn’t solve the problem, ensure that the “hosts” file isn’t read-only. Here’s how you can do it:

Right-click on the “hosts” file.

Click on “Properties.”

See “Read-only” in the popup.

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 popup, 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 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.

I hope this guide, “How to Fix Access is Denied While Editing Hosts File,” is helpful to you.

Thanks for reading.