[Easily] How to Edit Hosts File in Windows 10 and Windows 8.1

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

Edit Hosts File

We used to modify this 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 will get 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 which will not work on 64 Bit 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.

Easily Edit the Hosts File in Windows 10 and 8.1

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


host file location in windows 10

C – is the drive of Windows OS in most of the cases. If your OS is installed in a different partition, then you need to change this letter.

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, spyware or malware. If you face this issue, you need to disable the Antivirus software temporarily or exclude the hosts file from the protection.


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’. (This is an important step).

open command prompt as administrator

2) 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:\Windows\System32\Drivers\etc. Type ‘notepad hosts’ to open the 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/hostname and name of it. You can see the examples in the 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 facebook.com 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.

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.


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

5) Open the Notepad application with administrative access. Right-click and ‘Run as Administrator’.

Open Notepad As Admin

6) Browse the location of the hosts file, it’s under C:\Windows\System32\Drivers\etc. Change the file format to ‘All files’, then open the hosts file and modify the settings as you want.

Open The Hosts File In Notepad Windows 10

7) Save the file once changes are done. You should have open the Notepad as Administrator to apply the changes.

By this method, we have avoided using the command prompt.

Since these changes are related to DNS, you can clear the DNS cache on your PC before checking the impact of hosts file modification.

Open command prompt, and type;

ipconfig /flushdns

Why Modify Hosts file in Windows 10 or other Operating Systems?

This is an advanced user action and most of the time you do not need to touch the hosts file. Here are the possible scenarios you may need to modify it.

  1. Block a website by giving the wrong IP. So, the PC will get the IP from hosts file.
  2. You are testing a website which was migrated to a different host. Before changing the public DNS entries, you can modify the hosts file in your Windows 10 PC with the new web host IP and access the website by name from the browser.
  3. Unintentional changes by any programs or virus attacks to the hosts file and you need to edit and put back the normal settings.
  4. Manipulate the DNS entries. If you need to resolve a name to IP which can’t be done by the DNS servers. Then modifying the hosts file is the only one option.

Hope this guide is helpful in editing the hosts file on the Windows 10 and earlier Windows 8.1 and Windows 7.

Dinesh is the founder of Sysprobs and written more than 400 articles. Enthusiast in Microsoft and cloud technologies with more than 15 years of IT experience.

33 thoughts on “[Easily] How to Edit Hosts File in Windows 10 and Windows 8.1”

  1. Thanks a lot Dinesh. I was facing issue with editing host file in Windows 8 but now I learnt how to edit it. Thanks!

  2. Would people please stop saying that this does not work, of course it works. Read the article:

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

    If you do not understand that then you’re out of your depth. That is no-one’s problem but your own.

  3. simply run first NOTEPAD as administrator then click file>open then locate HOST at local disk>windows>system32>drivers>etc from there do any changes you want and just hit close and save

  4. It appears that Windows 8.1 now sets the file attribute to ‘Read Only’. If you go into properties and uncheck the box, you can edit the file normally without having to go through the copy and paste procedure.

  5. Well, I have to shout out a big thank you. This has been the one, and only clearly illustrated, clearly explained way to edit the host(s) file in order to validate PS Elements 13. All the ‘troubleshooting ‘ posts they have in their forums, etc, reference the host file, but the ‘how-to’s’ were useless. One thing I found repeatedly were the references to disabling the AV, which made sense, They also said to turn off the firewall, etc. When people posted the their Windows Defender had a msg that the app had been turned off.. and therefore another AV program must be running… well, that happened to me , as well. So, I turned off MalewareBytes, but ran into the same thing, over and over and over. So, I did more research and discovered that depending on which Windows operating system you have, what year you bought it, Windows revamped Defender, and renamed it Security Essentials, and sometimes the OS had both programs, so, at one point, or another I must have activated Security Essentials, which effectively disabled Defenders. I don’t remember doing it, forgot all about Security Essentials, until today. So, I search my pc for it, turned it off, followed your extremely well composed instructions. I, too, got the ‘ administer rights’ msg, but I had the option to ‘continue’, so I did. The hosts file saved, and I opened PS Elements, and low, and behold, I was able to validate my purchase. I cannot thank you enough.

  6. I am unable to follow those steps at the very end. I save the hosts file as “All file types” and yet, the file still comes out with a .txt extension. Why is that and how can I stop that from happening?

  7. I don’t get it…Why is it important to save as “all files”.. then it’s a different file extention and therefore won’t replace the original file, but just add a new “hosts” file…

  8. Hi,
    I’ve edited my hosts file but the saved file now has a .txt extension (and a different icon from the others in that folder). Does this matter and if so how can I change it back to what it was before? It seems to have defaulted to .txt as a result of editing with Notepad – help please!

  9. Hi! dinesh my hosts file is in fully chinese language & it is too much long… even the verticle scrollbar is left of 1 cm in size…
    I use windows 8.1. please help how to edit or change the language of hosts file. please.

  10. there are two notepad.exe in x64 windows,

    you must use full path c:\windows\system2\notepad.exe ,this one is 64 bit version,

    only type notepad whithout path may be launch 32 bit notepad.

    “Run as administrator” just let you enforce launch 64 bit notepad.exe

    using 32 bit software to edit c:\windows\system32\drivers\etc\hosts

    the x64 system will automatic redirect to c:\windows\syswow64\drivers\etc

    and there is no hosts file.

    the GUI stiil display current folder is c:\windows\system32

    but the real folder is c:\windows\syswow64

  11. …On keying “Notepad Hosts” notepad opens with on-screen message ‘Cannot find the Hosts.txt File’, followed by ‘Do you want to create a new file’ with options of ‘Yes’, ‘No’ and ‘Cancel’…

    As I have no knowledge of the Hosts File format I selected Cancel…

    Question: Is there a Windows Automated way to create the Host.txt file..? (so I can edit adding websites I’d like to block…)

    Win8.2 Pro

Comments are closed.

Pin It on Pinterest