Windows

What is the ETC Hosts File in Windows? Usage, Location, How to View and Edit, FAQ

  • Find out what the hosts file does, where is the etc folder in Windows, and how you can edit its contents.
  • There are tons of old tools buried deep inside Windows.
  • The ETC Hosts file is one of these remnants, dating back to 1984.

Operating systems are complex “creatures”, even if on the outside they look friendly. OSes are among the most complex pieces of software out there. It’s a miracle they’re friendly enough to get things done by non-technical people.

Windows is no different, and even if we’re talking about the fresh new version of Windows 11, underneath not every bit is new. For legacy and compatibility reasons Microsoft can’t start from the beginning with Windows, no matter how hard we wish they did.

In this article, we’ll be talking about the etc/hosts file, which dates back to something like 1984, the year, not the book. Funny enough, the etc/hosts file can be used to control people’s behavior, but let’s not spoil things from the beginning.

What is the ETC/Hosts File?

The etc/hosts file is a text document stored inside the Windows folder. It acts as a local DNS server, where you can manually specify which domain names load from which IPs. The hosts file entries will override DNS settings coming from the Internet servers.

etc hosts file contents

What’s the Location of the Hosts File? Where Is The etc Folder in Windows?

The hosts file is located in the etc directory in the Windows folder:

C:\Windows\System32\drivers\etc

Now you understand why it’s called etc/hosts, right?

etc hosts file location windows folder

How to View the Contents of the Hosts File?

Now, to view the hosts file contents do the following:

  1. Copy the path above.
  2. Open Windows Explorer (Win + E).
  3. Click on the address bar (or press Alt + D).
  4. Paste the path (Ctrl + V), then hit enter to open the hosts file location.

Since the hosts file is in text format you can use any text editor. And by any, I mean any program, even Notepad, which we’ll use for demo purposes.

  1. In the Windows Explorer window, right-click on the hosts file icon.
  2. Choose Open with.
  3. From the new popup click on Notepad and hit OK.
how to open file with notepad in windows

The file looks something like this. Below I’ve added the default version that comes with Windows 11. It’s surprisingly legible and has tons of useful info already laid out.

etc hosts file open in notepad

How Can You Edit the Hosts File in Windows?

Now, at this point, if you try and save the file, after modifying it (Ctrl + S), you’ll see the popup below, followed by a small error window that appears after you click Save.

etc hosts file cant save

That’s because you didn’t open Notepad with administrator privileges. The etc hosts file is a system file and can’t be modified by everyone. So, close the Notepad window, and let’s try again, but this time we’ll do things a bit differently.

1. Open the Start menu (press the Win key).

2. Type Notepad.

3. Right-click on the first result to open the contextual menu.

4. Click on Run as administrator.

start notepad as administrator

5. Select File > Open (or press Ctrl + O).

6. Navigate to the hosts file location.

7. If the folder appears empty it’s because in the open dialog window system files are hidden by default. Select All files (*.*) in the lower right dropdown menu.

open etc hosts file no extension

8. Select and open the hosts file.

9. Edit as you please then save with Ctrl + S.

That’s it, you’ve now modified the hosts file.

It would be a good idea to save a backup of the hosts file first, before editing. You can mess up quite a few things by mistake.

How to Add Info to the Hosts file?

The hosts file works like a table with two columns and an infinite number of rows.

You only need two bits of info on each row.

IPHost name
192.168.1.200binaryfork.com

The line above will try and load my site from a different IP. It won’t work with this particular IP.

The IP and the host name must be separated by at least a space. You can use more spaces for formatting purposes.

Anything that starts with a # on a row is a comment and will be ignored. You can add a comment after a pair of IP-hostname on the same row to ensure you remember what that line does. You’ll definitely forget.

What Can You Use the Hosts File For?

I’m not going to lie to you: the first time I heard about the hosts file I only saw the prank possibilities opening up. If you can edit the hosts file on a friend’s computer you can for example point google.com to the IP of bing.com. Some friend, right?

Anyway, that’s not what the hosts file is used for. Developers need to test apps and websites locally, and the hosts file is a great way to point the browser to the domain name of the website you’re working on, but make sure it loads from your computer, not from the Internet.

So, IT professionals are the types of people who use this old Windows functionality.

As with any tool, even the etc/hosts file can be used for malicious purposes. Some malware and viruses are using this file to point your browser to copies of the websites you’re using, just to steal your information. Be careful and if anything looks weird when browsing the web it could be a good idea to double-check the hosts file contents by using the guide above.

Frequently Asked Questions About the Hosts File

What is the 127.0.0.1 IP address?

This number is known as localhost or loopback address and is the IP that when used will open the browser pointing to the local computer. Imagine you need to call yourself on the phone, to see if the speaker is working. On a normal phone, you can’t do that. With computers, you can.

Web developers are the kind of people who need to use the localhost functionality. Localhost works even on a PC not connected to the Internet.

Avatar for Ionuț-Alexandru Popa
I'm a writer and Editor-in-Chief at BinaryFork. I am passionate about technology, science, space exploration, and movies. I started writing about tech more than 20 years ago, after graduating in Computer Science.
Want to work smarter, not harder? Join our FREE Newsletter
Learn tricks you can use daily to save time. You will also receive a PDF with the essential Windows 11 keyboard shortcuts.
SIGN ME UP!
We want to hear what you have to say:

Your email address will not be published. Required fields are marked *

Our readers appreciate heated debates, as long as they remain polite, so they ask for your respect, even if you don't completely agree with them. Thanks!

The written content on our website is available free of charge because of the ads we're showing. Please support our efforts and deactivate your AdBlocker when you visit our site. Thank you!
Join our FREE Newsletter and learn computer tips you can use to do things faster
Every subscriber receives a PDF with the essential Windows 11 keyboard shortcuts.
I WANT TO JOIN!