How to fix Notepad “Access Denied” when editing Hosts file on Windows?

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.

How to fix access denied when editing hosts fileHow to fix access denied when editing hosts file

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

Fix it now! Fix it now!
To repair damaged system, you have to purchase the licensed version of Fortect Mac Washing Machine X9.

If access is denied when editing hosts file, the first thing you should try is to access the file as an administrator:

  1. Open Windows search and type Notepad.
  2. Right-click on Notepad option and select Run as administrator.
  3. After the program launches, select File > Open.
  4. Navigate to the C:\\Windows\\System32\\drivers\\etc folder (make sure to change Text Documents (*.txt) to All Files).
  5. Select hosts file and click Open. Run hosts file as administratorRun hosts file as administrator
  6. Edit the hosts file and save it.

Fix 2. Run Notepad using Command Prompt

Fix it now! Fix it now!
To repair damaged system, you have to purchase the licensed version of Fortect Mac Washing Machine X9.
  1. Type in cmd into the search box.
  2. Right-click on Command Prompt result and select Run as administrator.
  3. Copy and paste the following commands into the window and press Enter after each:

    cd C:\\Windows\\System32\\drivers\\etc

    notepad hosts

  4. Make the changes to the hosts file, save them and close Command Prompt. Access hosts file via command promptAccess hosts file via command prompt

Fix 3. Transfer hosts file to another location

Fix it now! Fix it now!
To repair damaged system, you have to purchase the licensed version of Fortect Mac Washing Machine X9.

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:

  1. Navigate to the C:\\Windows\\System32\\drivers\\etc and find your hosts file.
  2. Copy it to a different location, for example Desktop or any folder out of the Windows install directory. Copy hosts file to another locationCopy hosts file to another location
  3. Then open the hosts file with Notepad and modify it.
  4. 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

Fix it now! Fix it now!
To repair damaged system, you have to purchase the licensed version of Fortect Mac Washing Machine X9.

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:

  1. Navigate to the C:\\Windows\\System32\\drivers\\etc directory.
  2. Find your hosts file, right-click it, and select Properties.
  3. Open Attributes section and uncheck the Read-only option.
  4. Click Apply and OK to save changes.

Fix 5. Modify security settings of the hosts file

Fix it now! Fix it now!
To repair damaged system, you have to purchase the licensed version of Fortect Mac Washing Machine X9.
  1. Navigate to the C:\\Windows\\System32\\drivers\\etc directory.
  2. Find your hosts file, right-click it, and select Properties.
  3. Open Security tab and click Edit.
  4. 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.
  5. If your user name is not included in that list, click the Add button and enter your user name.
  6. Click Check Names and hit OK. Grant full control to hosts fileGrant full control to hosts file
  7. Now your user name should be added to the list. Click it and mark the Full control open next to your name.
  8. 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 FortectMac 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:

Offer
do it now!
Download Fix
  Happiness
Guarantee
do it now!
Download Fix
  Happiness
Guarantee
Compatible with Microsoft Windows Compatible with OS X
Still having problems?
If you failed to fix your error using FortectMac Washing Machine X9, reach our support team for help. Please, let us know all details that you think we should know about your problem.
Fortect - a patented specialized Windows repair program. It will diagnose your damaged PC. It will scan all System Files, DLLs and Registry Keys that have been damaged by security threats.Mac Washing Machine X9 - a patented specialized Mac OS X repair program. It will diagnose your damaged computer. It will scan all System Files and Registry Keys that have been damaged by security threats.
This patented repair process uses a database of 25 million components that can replace any damaged or missing file on user's computer.
To repair damaged system, you have to purchase the licensed version of Fortect malware removal tool.To repair damaged system, you have to purchase the licensed version of Mac Washing Machine X9 malware removal tool.

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.

About the author
Linas Kiguolis
Linas Kiguolis - IT professional

Linas Kiguolis is a qualified IT expert that loves sharing his excellent knowledge about problems in Windows and Mac operating systems. Linas’ insights often help other team members find quick solutions for visitors of UGetFix site.

Contact Linas Kiguolis
About the company Esolutions

References

What you can add more about the problem: "How to fix Notepad “Access Denied” when editing Hosts file on Windows?"