How-To

How to Edit the Hosts File in Windows 10

How to Edit the Hosts File in Windows 10

There’s an easy way and a hard way to edit the hosts file in Windows 10. In this article, we’ll show you both.

If you’re a regular groovyPost reader, you know that DNS translates domain names like groovyPost.com into IP addresses like 104.24.11.25. But did you know that there’s a file on your Windows 10 PC that can override that? It’s called your hosts file and it lets you map specific domain names to an IP address of your choosing. Your hosts file only affects your computer, so you can use it to create custom URLs for IP addresses on your network, or you can use it to redirect certain websites.

As you can imagine, editing the hosts file can easily break your internet if it’s modified incorrectly or maliciously. So, it’s not particularly easy for a normal user to edit. This is a good thing. But if you want to change your hosts file purposefully, here’s how.

Edit Your Windows 10 Hosts File as an Administrator

The hosts file is normally stored in a plain text file in the Windows System folder and can be modified for various use cases. One particular reason I edited the hosts file in the past was to block certain websites when I managed computers for a local high school. This was probably one of the best and easiest ways I could ensure students didn’t load any unauthorized websites such as Facebook or YouTube.

Editing your Windows hosts file doesn’t have to feel like going down a rabbit hole. In Windows XP and earlier versions, the process was quite easy. All you needed to do was add an exception to your antivirus, open the file in Notepad, make your changes, and then save it.

In Windows 10, if you try to edit your hosts file, you’ll probably be able to open it just fine, but when you go to save it, you’ll get an error:

no permission to edit hosts file error

Here’s how you can edit your hosts file without getting the “You don’t have permission to save in this location. Contact the administrator to obtain permission” error.

  1. Click the Start menu or press the Windows key and start typing Notepad.
  2. Right-click Notepad and choose Run as administrator.
    Run Notepad as administrator
  3. In Notepad, click File then Open… In the File name field, paste the following path:
    c:\Windows\System32\Drivers\etc\hosts

    choose hosts file

  4. Now you’ll be able to edit and save changes to your hosts file.
    hosts file open in Notepad
  5. To map a domain, add a line based on the examples in the hosts file.
    1. Start with the target IP address, then a space, then the domain name. If you want to block a website, redirect it to 127.0.0.1.
    2. Don’t put in the # if you want it to take effect.
    3. Also, remember that www.youtube.com is different from youtube.com.

You may need to restart your computer for the new hosts file to take effect.

An Easier Way to Edit the Hosts File in Windows 10

If you found that process a bit cumbersome, there’s a third-party utility you can use to modify your hosts file. I found a good one called Hosts File Editor by Scott Lerch. Let’s take a look and see how it works.

  1. Download the 1 MB installer, then proceed to set it up. Remember to choose the option just for yourself if you don’t want other users to access it.
    Installing Hosts File Editor
  2. Launch the app in Start > All apps—this will add the app to the Notification area, where you can launch the editor anytime you need to.
    Hosts File Editor in Start Menu

Hosts File Editor features a clean, easy-to-use interface. To begin using the program, populate the table with IP Addresses, Host Names, and comments on the websites you want to manage. It’s not just limited to popular Internet websites. Even devices on your home network with an IP address can be managed, so your Xbox, iPad, web cameras, or routers are much easier to block access to if needed.

Hosts File Editor interface

When you are ready to block a website, check the box for the sites you want to prevent access to, click Save, and that’s it.

Making changes to hosts file

Another nice ease-of-use feature is the ability to right-click the Hosts File Editor in the Notification area, click Disable Hosts File, or make a quick edit. No need to go hunting or launch the command line anymore.

Hosts File Editor in notifications center

There are some other cool features included for power users and network administrators, such as:

  • Cut, copy, paste, duplicate, enable, disable, and move one or more entries at a time.
  • Filter and sort when there are a large number of host entries
  • Archive and restore various hosts file configurations when switching between environments
  • Automatically ping endpoints to check availability

So, there you have it, a quick and easy way to edit your Hosts File in Windows 10.

9 Comments

9 Comments

  1. Harry Frank

    June 27, 2018 at 4:04 pm

    Followed all of your instructions for editing the HOSTS file. Even running notepad in administrator mode, I still get the “you do not have permissions . . .” message. Has Win 10 made changes subsequent to your posting?

    • Steve Krause

      June 28, 2018 at 10:50 am

      Hi Harry – Nope, process is still the same with the latest version of Windows 10.

      Confirm you are Admin on the PC you’re trying to do this on. If you’re not an Admin, it won’t work. You can also try this:
      Click Start Button > Type: CMD > Right Click Command Prompt > Click Run as Administrator > goto c:\windows\system32\drivers\etc > type: notepad hosts

      Make your changes, save and you should be golden.

    • DANA C SNELL

      July 10, 2019 at 10:57 pm

      I had this same problem but found that my anti-virus software was blocking it,try disabling it and try again.

  2. brant

    January 29, 2019 at 4:33 pm

    Tried both options. notepad is not recognized in cmd shell and there is nothing in the etc directory.

  3. brant

    January 29, 2019 at 4:44 pm

    I got to etc and see that they are hidden files. No problem except notepad and or wordpad are not recognized in a cmd shell.

  4. Joes Boerma - portrettist

    May 27, 2019 at 6:01 am

    Hello Andre,
    thank you so much for giving me this helping hand after hours and hours of searching.

    Trying to set up a testing environment for a new website, I needed to add two local hosts in the hosts file. I ran into two problems.
    a) – The hosts file was not in drivers/etc/. FileFind did the job and found in some obscure location; maybe a backup inside windows.
    Opening the file there gave me the same screen as you show here, preventing me from editing. Not being a network ‘guru’, that looked like a lot of trouble. Never giving up. I have no choice.
    b)- once more looking in c:/windows/system32/drivers/ I was unable to find the directory /etc. Typed etc in de next step for opening a file. And that brought me to that invisible dir etc. And there was the hosts file too!
    After editing, I closed the file with just ‘save’, not ‘save as’. After that the hosts file was updated.

    Blocking unwanted sites is a great possibility, it stopps certain websites from following a user browsing the net.

    Happy with your help.
    Greeting from The Netherlands.

  5. Atif Perwez

    May 28, 2019 at 3:53 am

    I have done as you told and I open as administrator and change the file but when I am saving it. It is saving in txt file and when I am forcing it to save as host it saying the file is read-only you can’t make changes.

  6. Grimaldi lines

    July 11, 2019 at 8:05 pm

    Wonderful post but I was wondering if you could write a litte more on this
    topic? I’d be very thankful if you could elaborate a little bit more.
    Bless you!

  7. Ayla

    September 19, 2019 at 8:38 am

    You people that are saying there’s nothing there well notepad no matter how you open it is looking for text while so you have to change it to all files to see anything there. I also cannot use the go to command in the CMD program as it will not go past the system32 folder. I have tried everything I can with administrator privileges and cannot change this damn file even in safe mode with the internet turned off. I have tried security settings for the file and it does not work. You’ll see a million bits of advice saying the same thing on every website but this file is getting really stupidly hard 2 Chainz even though most of the time it is never used.

To Top