In this tutorial, you will learn how to edit the Windows hosts file in an easy way without any tool from the 3rd party. Hosts File is an important system file, where storages the IP information that the serves navigate to. It is used to block or permit the IP or the Websites address work or not in an effective way. However, in some cases, you cannot edit the Windows hosts file, so what can we do?

Some antivirus software including Microsoft Security Essentials (Windows Defender) will not allow users to modify the hosts file for the security reasons. That means if you want to face with this problem, you have to disable the antivirus software temporarily or exclude files from the protected host. But for some other reason, you cannot disable antivirus software, or exclude from your hosts file so what can be done next?

Using a Command Prompt

First, open the Command Prompt window by the highest authority by typing “cmd” into the search box in the Windows > Right-click on the “Command Prompt”> Click on the “Run as administrator” (or by the simplest way you can press Windows + X and then click on Command Prompt (Admin).

edit the hosts file in Windows 10 when blocked
Click on the “Run as administrator”


On the “Command Prompt” window, type “cd drivers’ then press Enter, type ”cd etc” and press Enter to access the hosts file location.

edit the hosts file in Windows 10 when blocked
“Command Prompt” window

Please make sure you are in the right directory “C: Windows System32 Drivers etc”> then type “notepad hosts” to open the hosts file in Notepad.

edit the hosts file in Windows 10 when blocked
Type “notepad hosts” to open the hosts file in Notepad.

Then you proceed to change the hosts file contents (below is an example, if I want to block facebook on the computer, I can enter the IP address and type facebook.com) > Then go to Menu File > select Save and i have changed the Windows hosts file successfully.

edit the hosts file in Windows 10 when blocked
Block facebook on the computer

Important note: If you do not open the notepad by “Run as Administrator”, you cannot save the hosts file.

We have told you how to edit the hosts file in Windows 10 when blocked. Finally, if your find this article useful, let’s share to your friends. If you have any questions, please leave your comments in the box below. We are happy to receive your feedback. Thank you!