Question
Issue: How to fix Notepad “Access Denied” when editing Hosts file on Windows?
I was recently infected with ransomware, and I read on the instructions online that I need to modify the file in order to regain normal internet access. After I edit it and try to save it, however, it returns an error “Access denied.” Any idea how to bypass that? Thanks.
Solved Answer
Hosts file is a simple text file located inside C:\\Windows\\System32\\drivers\\etc\\ folder on Windows XP, 7, 8, and 10 operating systems. In some cases, it might be hidden, so users might not immediately see it, as they would have to enable the “View hidden items” feature via File Explorer. Essentially, Hosts file was used for Name to IP address resolution, although modern DNS[1] features quickly replaced it.
However, Hosts file still manages to find various uses in modern times, and is especially useful for people from the IT field, such as web developers or networking administrators, as they can develop websites locally or filer various content.
Unfortunately, the Hosts file can also be abused by cybercriminals to prevent users from accessing specific websites (for example, Djvu ransomware[2] is known to use this feature to stop victims from visiting sites that would help them with malware removal or file retrieval process). In such a case, users might want to edit the Hosts file to bypass these malware-set restrictions.
However, many users find themselves in a situation where access is denied when editing hosts file on Windows. The pop-up message is very simple and does not provide any explanations:
Access is denied
OK
Before the emergence of the DNS, hosts files have been used for resolving hosts names. These files have a distinct syntax, which is easily recognizable on every operating system, including Windows, macOS, or Linux.[3] Therefore, the modification of the hosts file should be initiated in a very careful manner to prevent file damage. Due to this, the hosts file is often hidden, and access to it is restricted by the Windows OS itself.
In most of the cases, the “Access is denied” error aborts editing hosts file because the user does not have permission. The hosts file is located in the Windows installation directory, also known as root drive. The file is protected from unauthorized access, so if you’re not an authorized user of the target PC, you may encounter “Access is denied” error on Notepad.
Luckily, you can fix Access denied when editing hosts file error relatively easily – simply follow the steps provided below.
Fix 1. Launch Notepad as administrator
If access is denied when editing hosts file, the first thing you should try is to access the file as an administrator:
- Open Windows search and type Notepad.
- Right-click on Notepad option and select Run as administrator.
- After the program launches, select File > Open.
- Navigate to the C:\\Windows\\System32\\drivers\\etc folder (make sure to change Text Documents (*.txt) to All Files).
- Select hosts file and click Open.
- Edit the hosts file and save it.
Fix 2. Run Notepad using Command Prompt
- Type in cmd into the search box.
- Right-click on Command Prompt result and select Run as administrator.
- Copy and paste the following commands into the window and press Enter after each:
cd C:\\Windows\\System32\\drivers\\etc
notepad hosts
- Make the changes to the hosts file, save them and close Command Prompt.
Fix 3. Transfer hosts file to another location
To fix “Access denied” alert while editing hosts file, try to move hosts file to a different location. Then edit it and move back to the initial location:
- Navigate to the C:\\Windows\\System32\\drivers\\etc and find your hosts file.
- Copy it to a different location, for example Desktop or any folder out of the Windows install directory.
- Then open the hosts file with Notepad and modify it.
- Save the changes. Then cut the file and paste it back to the C:\\Windows\\System32\\drivers\\etc directory.
Fix 4. Unmark Read-only option
Hosts file is set to Read-only by default. It means that the file cannot be edited in a regular way. To get permission to modify it, you should:
- Navigate to the C:\\Windows\\System32\\drivers\\etc directory.
- Find your hosts file, right-click it, and select Properties.
- Open Attributes section and uncheck the Read-only option.
- Click Apply and OK to save changes.
Fix 5. Modify security settings of the hosts file
- Navigate to the C:\\Windows\\System32\\drivers\\etc directory.
- Find your hosts file, right-click it, and select Properties.
- Open Security tab and click Edit.
- Check the list of users that have access to hosts file. If your user name is included in that list, click it and set Permissions to Full control.
- If your user name is not included in that list, click the Add button and enter your user name.
- Click Check Names and hit OK.
- Now your user name should be added to the list. Click it and mark the Full control open next to your name.
- Click Apply and OK to save the changes.
Note: if your system was infected with ransomware or other malware which modified your hosts file, there is a high chance that your system files were affected as well. Due to this, the OS might experience slowdowns, errors, or even crashes, consequently pushing a thought of many to reinstall Windows altogether. To avoid that, we highly advise using RestoroMac Washing Machine X9 – it can fix virus damage easily and stabilize the system without having to reinstall it.
Repair your Errors automatically
ugetfix.com team is trying to do its best to help users find the best solutions for eliminating their errors. If you don't want to struggle with manual repair techniques, please use the automatic software. All recommended products have been tested and approved by our professionals. Tools that you can use to fix your error are listed bellow:
Protect your online privacy with a VPN client
A VPN is crucial when it comes to user privacy. Online trackers such as cookies can not only be used by social media platforms and other websites but also your Internet Service Provider and the government. Even if you apply the most secure settings via your web browser, you can still be tracked via apps that are connected to the internet. Besides, privacy-focused browsers like Tor is are not an optimal choice due to diminished connection speeds. The best solution for your ultimate privacy is Private Internet Access – be anonymous and secure online.
Data recovery tools can prevent permanent file loss
Data recovery software is one of the options that could help you recover your files. Once you delete a file, it does not vanish into thin air – it remains on your system as long as no new data is written on top of it. Data Recovery Pro is recovery software that searchers for working copies of deleted files within your hard drive. By using the tool, you can prevent loss of valuable documents, school work, personal pictures, and other crucial files.
- ^ Domain Name System. Wikipedia. The free encyclopedia.
- ^ What is Ransomware?. Forcepoint. Human-Centric Cybersecurity.
- ^ What is Linux?. Opensource. Community program.