How to Edit Hosts File in Windows 10 and Windows 8.1

This guide shows you how to edit hosts file in Windows 10 and Windows 8.1 easily without any additional system tools. Hosts file is an important system file which maps the host/site names with it’s IP addresses. Basically it translates the host name to IP and IP to host name. So the browsing and accessing other network places/shares by ‘name’ will be smoother by avoiding DNS server requests. We can manually customize DNS name and IP address for specific sites in this file which will be helpful in several ways in Windows or Mac OS X. Hosts file is a plain text file without any file extension.

We used to modify the hosts file by ‘edit’  DOS command in earlier Windows operating systems, but the edit DOS command is not included in Windows 8.1 and 10. You would be getting the following error message when you try edit command in Windows 10/8.1 command prompt.

“ ‘edit’ is not recognized as an internal or external command, operable program or batch file.”

edit command error

This is because of edit DOS command requires 16-bit QBASIC.EXE and it will not work on 64Bit version of Windows 8.1 and Windows 10. So how to edit the hosts file here?, we can use the built-in Notepad program for this purpose.

Let us Easily Edit the Hosts File in Windows 10 and 8.1

On Windows Operating Systems, the hosts file is located here ,


host file location in windows 10
C – is the drive Windows OS had been installed.

Make sure you have administrative access/privilege on the computer before attempting to modify it.

Important Note : Some of the Antivirus software including Microsoft Security Essential (Windows Defender) will not allow modifying hosts file as a security precaution. This is to prevent hosts file modification by any virus, spywares or malware. If you face this issue, you need to disable the Antivirus software temporarily or exclude the hosts file from the protection.

Method-1: Easily Edit the Host File in Windows 10/8.1

1) Open the command prompt as administrator.

Search ‘cmd’ on Windows 10 or 8.1 and right click on the Command Prompt and select ‘Run as administrator’.

open command prompt as administrator

2) On the opened command prompt, type ‘cd drivers’ ENTER then ‘cd etc’ ENTER as shown below. This is to go to the location where the host file is located.

host file in windows 10
3) Make sure you are in the correct folder path, it should be C:WindowsSystem32Driversetc. Type ‘notepad hosts’ to open the hosts file in notepad.

open hosts file in notepad
4) We assume that you know the content of the file. Type the IP address of the domain/host name you want to give, then name. You can see the examples in same file.

Here is an example, if I need to block facebook on a PC, I can enter the wrong IP address and map it to as we showed here.

how to edit host file in Windows 10 Once you have modified the file with appropriate settings, click Save from File menu. That’s it, we have successfully modified the hosts file in Windows 10/8.1 now.

Important Note: If you haven’t opened the notepad from ‘Run as Administrator’ command prompt, then you can’t save the Hosts file as shown above. Method-2 should be used in this case.


If you are not good in using command prompt, then this method will be handy in editing the hosts file in GU interface.

5) Browse the location of hosts file, it’s under C:WindowsSystem32Driversetc. Once you have located the file right click on it and open with notepad.

open with notepad in windows 8.1

6) Modify the hosts file properly. Click Save to apply the changes.

save host file

7) Unfortunately you can’t save this file now, overwriting is not permitted.  Therefore save the modified file to different location, make sure you are saving it as ‘hosts’ and selecting the file type as ‘All Files’ as shown below.

save the host file

I have saved the new hosts file on my desktop.

8.) Now simply copy or cut the file (from Desktop in this case) and paste it at the correct location, C:WindowsSystem32Driversetc.

Since the same file is already available at this location, you need to accept replacing the existing hosts file.

replace host file

Once you have replaced the file, the new edited hosts file will be active on your Windows 10 or Windows 8.1 computer. You can find the similar method but with more explanation at this site.

Hope this guide will be helpful in editing the hosts file on the latest Windows 10 or earlier Windows 8.1 and 8 versions.


    • Geraldo
  1. Thanh Frame
  2. camila
  3. Victor
  4. Geraldo
  5. David Schneider Friedrich
    • Ab Jefferson Andres
      • David Schneider Friedrich
  6. EddyMark

Leave a Reply