How to Edit Hosts File in Windows 10/Windows 7

Following tutorial explains how to edit hosts file in windows 10 operating system. In the early age of the Internet, there was not many computers, so the instead of DNS servers, the hosts file is used for the name resolution.

The hosts file still Exist in almost every operating system. On a Windows system you can locate the hosts file under the "C:\Windows\System32\drivers\etc" folder. The file is called hosts (no extension).

As shown in the following image, Windows hosts file shows a domain name and its corresponding IP address. All the lines start with a pound sign (#) you see in the hosts file are comments.

Windows hosts file shows a domain name and its corresponding IP address.

However, to edit this file you need administrative privileges. So first we need to open our text editor (Notepad) as administrator, then we can open and edit the Windows 10 hosts file.

  1. Open Notepad - Click on the start button, go to All apps > Windows Accessories and right click on the Notepad and click: "Run as administrator".
  2. Open the hosts file - Now from the Notepad, go to File > Open and open the hosts file from the  "C:\Windows\System32\drivers\etc" folder (make sure "All Files" option is selected).
Open Notepad as administrator
Edit hosts file in windows 10

Now you can add DNS entries to the file. First add the IP addresses, followed by some whitespace (tabs or spaces), followed by the computer/domain name.

The Windows domain name lookup software looks first in the hosts file before consulting DNS servers. If an entry found in this file, Windows will not communicate with a DNS server to obtain the IP address for the given domain name.