Share this article
Improve this guide
Fix Access Denied When Editing Hosts File in Windows 10/11
You need to log in as administrator to edit the hosts file
5 min. read
Updated onOctober 29, 2024
updated onOctober 29, 2024
Share this article
Improve this guide
Read our disclosure page to find out how can you help Windows Report sustain the editorial teamRead more
Sometimes in order to fix a certain problem or to block a certain website on your Windows 10 PC, you have to edit the hosts file. Editinghostsfile is a relatively advanced procedure, and a number ofusersreportedAccess deniedmessage while trying to edit thehostsfile onWindows 10.
The hosts file is located in yourWindows 10installation directory, and it’s protected from unauthorized access, but if you need to edit the hosts file, you can avoid“Access denied”message by following one of our solutions.
What can I do if I have no permission to edit hosts file?
1. Run Notepad asadministrator
If youuse Notepadas your text editor, you need to run it asadministratorbefore you can edit the hosts file. To run Notepad asadministratorand to edit thehostsfile, do the following:
We have to mention that this solution should work with any other text editor, so if you don’t use Notepad, just run your desired text editor asadministratorand you should be able to edithostsfile without any problems.
Alternatively, you can start Command Prompt asadministratorand use it to start Notepad and edit the hosts file. To do that, follow these instructions:
2. Copy thehostsfile to a different location
3. Make surehostsisn’t set to Read-only
Now you should be able to make the necessary changes to the hosts file. After you’re finished, it might be a good idea to sethostsfile back to Read-only mode again.
Sometimes, all your documents are read-only, including your hosts file. If you want to change them properly, you can find more info about that inthis quick guide.
4. Change the security settings forhosts
5. Use the hiddenadministratoraccount
Most system files are protected, therefore you need anadministratoraccountin order to make changes to them. Sincehostsare one of the system files, it requires anadministratoraccountin order to edit it.
If you don’t use anadministratoraccount, you can enable a hiddenadministratoraccountand use it to make the changes to the hosts file.
After you made the changes to the hosts file, you can come back to your originalaccount, start Command Prompt asadministratoragain and enternetuseradministrator/active:noto disable the hiddenadministratoraccount.
Here are some more examples of this problem:
The hosts file is a system file, so it’s protected, and usually, it’s not advised that you edit it, but if you decide to do so, it’s always good to knowhow to reset hosts file to default in Windows 10in case anything goes wrong.
If you have any more questions, feel free to leave them in the comments section below.
More about the topics:File Explorer,Fix corrupt files,windows 10
Milan Stanojevic
Windows Toubleshooting Expert
Milan has been enthusiastic about technology ever since his childhood days, and this led him to take interest in all PC-related technologies. He’s a PC enthusiast and he spends most of his time learning about computers and technology.
Before joining WindowsReport, he worked as a front-end web developer. Now, he’s one of the Troubleshooting experts in our worldwide team, specializing in Windows errors & software issues.
User forum
4 messages
Sort by:LatestOldestMost Votes
Comment*
Name*
Email*
Commenting as.Not you?
Save information for future comments
Comment
Δ
Milan Stanojevic
Windows Toubleshooting Expert
Before joining WindowsReport, he worked as a front-end web developer. Now, he’s specialized in Windows errors & software issues.