How to Fix Access is Denied While Editing Hosts File

You may face “Access is denied” error while opening, saving, or editing “hosts” file in Windows 10.

In this post, we’ll see two unique methods to fix it. Let’s begin.

Note: The “hosts” file is in C: > Windows > System32 > drivers > etc.

Read: How to Block Websites in Windows 10

How to Fix Access is Denied While Editing Hosts File

Method #1

Launch Notepad as administrator. Hit File > Open. Go to this location – C: > Windows > System32 > drivers > etc.

Open the drop-down list above the “Open” button and choose “All Files.” Select the “hosts” file. Click on the “Open” button.

Notes:

  • If you’re not using Notepad, then open the text editor program you use as an administrator and then open the “hosts” file in it.
  • If you’re still facing any issue, make sure the “hosts” file isn’t set as read-only. Here’s how you can do that: Right-click on the “hosts” file. Hit “Properties.” See “Read-only” in the pop-up. If it is unselected, close the pop-up. Else, unselect it, and hit the “Ok” button.

Alternative Method

Launch Command Prompt as administrator.

Provide the following command and then hit the “Enter” key. Here’s the command: cd c:\windows\system32\drivers\etc

Provide the following command and then hit the “Enter” key. Here’s the command: notepad hosts

Note: If you’re still facing any issue, make sure the “hosts” file isn’t set as read-only. Here’s how you can do that: Right-click on the “hosts” file. Hit “Properties.” See “Read-only” in the pop-up. If it is unselected, close the pop-up. Else, unselect it, and hit the “Ok” button.

Method #2

Copy the “hosts” file to the desktop. Once you finished the work and saved the file, cut the “hosts” file in the desktop and paste it in the “etc” folder, which you can find in C: > Windows > System32 > drivers.

In the pop-up, hit “Replace the file in the destination.” Hit “Continue” button.