Fix Access denied when editing hosts file in Windows 10

What is a hosts file in Windows 10?

IP addresses . A host file helps in addressing network nodes in a computer network. A hostname is a human-friendly name or label assigned to a device (a host) on a network and is used to distinguish one device from another on a specific network or over the internet.

If you have been a tech-savvy person, you would be able to access and modify the Windows hosts file to solve certain issues or block any websites on your device. The hosts file is located at C:\Windows\system32\drivers\etc\hosts on your computer. Since it is a plain text file, it can be opened and edited in notepad. But Sometimes you may encounter ‘Access Denied’ error while opening hosts file. How will you edit the host file? This error will not let you open or edit the hosts file on your computer. In this article, we will discuss various methods to solve Can’t edit the hosts file on Windows 10 issue.

Editing a hosts file is possible and you might need to do it for a variety of reasons.

  • You can create website shortcuts by adding a required entry in the hosts file that maps the website IP address to a hostname of your own choice.
  • You can block any website or ads by mapping their hostname to the IP address of your own computer which is, also called loopback IP address.

Fix Access denied when editing hosts file in Windows 10

create a restore point  just in case something goes wrong.

Why can’t I edit the hosts file, even as Administrator?

built-in Administrator account to modify or edit the hosts file, you are still unable to make any changes to the file itself. The reason being that the access or permission required to make any changes to the hosts file are controlled by TrustedInstaller or SYSTEM.

Method 1 – Open Notepad with Administrator Access

text editor on Windows 10. Therefore, before you edit the host file, you need to run Notepad as Administrator on your device.

1. Press Windows Key + S to bring up the Windows Search box.

2. Type notepad and in the search results, you will see a shortcut for Notepad.

3. Right-click on Notepad and select ‘Run as administrator’ from the context menu.

4. A prompt will appear. Select Yes to continue.

5. Notepad window will appear. Select File option from the Menu and then click on ‘Open‘.

6. To open the hosts file, browse to C:\Windows\system32\drivers\etc.

7. If you can’t see the hosts file in this folder, select ‘All Files’ in the option below.

8. Select the hosts file and then click on Open.

9. You can now see the contents of the hosts file.

10. Modify or make the required changes in the hosts file.

11. From Notepad menu go to File > Save or press Ctrl+S to save the changes.

It is important to note that this method works with all text editor programs. Therefore, if you use another text editor program apart from notepad, you just need to open your program with Administrator access.

Alternative Method:

Alternatively, you can open the notepad with admin access and edit the files using the Command Prompt.

1.Open the command prompt with admin access. Type CMD in Windows search bar then right-click on Command Prompt and choose Run as administrator.

2.Once the elevated command prompt opens, you need to execute the below-given command

3.The command will open the editable host file. Now you can make the changes to the hosts file on Windows 10.

Method 2 – Disable Read-only for the hosts file

By default, the hosts file is set to open but you cannot make any changes i.e. it is set to read-only. In order to fix Access denied when editing hosts file error in Windows 10, you need to disable the read-only feature.

1.Navigate to C:\Windows\System32\drivers\etc.

2.Here you need to locate the hosts file, right-click on it and choose Properties.

3.In the attribute section, uncheck the Read-only box.

4.Click Apply followed by OK to save the settings

Now you can try to open and edit the hosts file. Probably, the problem of access denied will be solved.

Method 3 – Change the Security settings for the hosts file

requires special privileges . It could be one reason that you may not be given full access, therefore, you are getting access denied error while opening hosts file.

1.Navigate to C:\Windows\System32\drivers\etc.

2.Here you need to locate the hosts file, right-click on the file and choose Properties.

3.Click on the Security tab and click on the Edit button.

4.Here you will find a list of users and groups. You need to ensure that your user name has full access and control. If your name is not added in the list, you can click on the Add button.

‘Enter the object name to select’ and click OK. 

lick on “Find now” button.

7.Finally, click OK and checkmark “Full Control”.

8.Click Apply followed by OK to save changes.

Hopefully, now you will be able to access and edit the hosts file without any issues.

Method 4 – Change the hosts file location

Some users noted that changing the file location has solved their problem. You can change the location and edit the file thereafter put the file back to its original location.

1.Navigate to C:\Windows\System32\drivers\etc.

2.Locate the Hosts file and copy it.

3.Paste the copied file on your Desktop where you can easily access that file.

4.Open the hosts file on your Desktop with Notepad or another text editor with Admin access.

5.Make the necessary changes on that file and save changes.

6.Finally, copy & paste the hosts file back to its original location:



  • Create Multiple Gmail Accounts Without Phone Number Verification
  • Identify and Install Missing Audio & Video Codecs in Windows
  • Fix The Diagnostics Policy Service Is Not Running Error
  • 10 Ways To Fix Slow Page Loading In Google Chrome

That’s if you have successfully Fix Access denied when editing hosts file in Windows 10 but if you still have any queries regarding this article then please feel free to ask them in the comment’s section.