GuideWindows 10/11

How to edit the hosts file in Windows 11 and 10.

The hosts file is a plain text file that tells Windows which IP address to use for a domain name before it asks DNS. Editing it lets you block a website, point a name at another address or test a server. Saving changes needs administrator rights.

This guide shows the manual way with Notepad, the usual problems and how to fix them, and a faster way if you do this often.

Windows 10 · Windows 11 About two minutes
Notepad has to run as administrator, or Windows will refuse to save
# where it lives

Where the hosts file is

The path is the same on Windows 10 and Windows 11. The file has no extension.

Path to the file

Paste it into the File Explorer address bar.

C:\Windows\System32\drivers\etc\hosts
# the file is called hosts, with no .txt
  • The file is called hosts, with no .txt or any other extension.
  • You can read it in any text editor, but saving needs administrator rights.
  • Make a copy first: copy hosts as hosts.bak in the same folder. Windows asks for permission once.

What a hosts line looks like

One line is one entry.

# a comment starts with a hash
0.0.0.0 ads.example.com
127.0.0.1 test.example.com
# 0.0.0.0 www.example.com
  • An IP address first, then a space or a tab, then the domain name.
  • Everything after # is ignored, so you can switch a line off by putting # in front of it.
  • There are no wildcards: every subdomain needs its own line.
  • 0.0.0.0 is the usual address for blocking a domain, because the connection fails straight away.
# steps

Edit the hosts file with Notepad

The manual way works on every Windows 10 and 11 PC and needs no extra software.

  • 1Make a backup. In File Explorer open C:\Windows\System32\drivers\etc, copy the hosts file and paste it as hosts.bak. Windows asks for permission once. If something goes wrong, you can put the original back.
  • 2Run Notepad as administrator. Click Start, type Notepad, right-click the result and choose Run as administrator. Confirm the prompt.
  • 3Open the file. In Notepad choose File → Open, paste C:\Windows\System32\drivers\etc into the address bar and press Enter.
  • 4Show all files. Change the file type box from Text Documents (*.txt) to All files, then pick hosts. Otherwise the folder looks empty.
  • 5Add your lines at the end, one per line, for example 0.0.0.0 example.com. Finish the last line with Enter.
  • 6Save with Ctrl+S.
  • 7Flush the DNS cache. Open Command Prompt or Terminal and run ipconfig /flushdns. Restart your browser and test the domain.

Good to know

So nothing surprises you.

  • Changes usually apply immediately. Flushing DNS and restarting the browser covers the rest.
  • The file must keep the name hosts, with no extension. If you end up with hosts.txt, rename it.
  • Some security programs warn about changes to the hosts file or undo them. If your entries keep disappearing, check your antivirus settings.
Tip

Add a comment above your changes (for example # blocked for the kids, Nov 2026) so you remember why they are there.

# troubleshooting

When it doesn’t work

The usual problems, and what fixes them.

I can’t save the file

Almost always a permissions problem.

  • “You don’t have permission to save in this location” means Notepad is not running as administrator. Close it and open it again with Run as administrator.
  • Read-only or locked file. Right-click hosts, open Properties and clear Read-only. Some security software also protects the file.
  • It saved as hosts.txt. Rename it to hosts. Turn on file name extensions in the Explorer View menu to see the extension.

Saved, but nothing changed

Go through these in order.

  • Flush the DNS cache: run ipconfig /flushdns in Command Prompt or Terminal.
  • Restart the browser. Browsers keep their own DNS cache.
  • Secure DNS, VPN or proxy. Some browser features, VPN apps and proxy extensions can bypass the hosts file. Switch them off to test.
  • Check the line. An IP address, a space or tab, then the name. No http://, no slashes, no port numbers.
  • Subdomains. Blocking example.com does not block www.example.com. Add both.
# the easier way

Edit it without Notepad

If you change the hosts file often, doing it by hand gets old. HOTS Hosts and HOTS Hosts Lite are free, open-source hosts file editors for Windows.

HOTS Hosts

The full version, with parental controls and privacy tools.

  • Asks for administrator rights when it starts, so saving the file works without extra steps.
  • Keeps backups of the hosts file.
  • Category blocklists for parental controls and privacy.
  • Diagnostics: a malware scanner and a domain existence check.
See HOTS Hosts

HOTS Hosts Lite

The lighter edition.

  • Hosts file lock against unwanted changes.
  • Custom domain blocking.
  • Three saved profiles.
  • Per-app firewall blocking and speed tests.
See HOTS Hosts Lite
# faq

Questions people ask

Where is the hosts file in Windows 11?
In the same place as in Windows 10: C:\Windows\System32\drivers\etc\hosts. The file has no extension. Open it with a text editor that is running as administrator.
Why can’t I save changes to the hosts file?
Almost always because the editor is not running as administrator. Close Notepad, open it again with Run as administrator and reopen the file. If it still fails, check whether the file is marked read-only or protected by security software.
Do I have to restart Windows after editing it?
No. Changes usually apply immediately. If a site still loads the old way, run ipconfig /flushdns and restart your browser.
What is the difference between 127.0.0.1 and 0.0.0.0?
Both stop the domain from reaching the real server. 127.0.0.1 points it at your own PC, while 0.0.0.0 is an address that cannot be connected to, so the request usually fails straight away. Many blocklists use 0.0.0.0.
Can I block a whole domain with a wildcard?
No. The hosts file has no wildcards. Every name, including www and other subdomains, needs its own line.
How do I restore the default hosts file?
Remove the lines you added and keep the commented lines that start with #. The default file on Windows 10 and 11 contains only comments, so an empty-looking file is normal. You can also copy your hosts.bak backup back.
Is it safe to edit the hosts file?
Yes, if you only add lines you understand and keep a backup. A wrong entry can make a site unreachable, and malware sometimes adds entries to this file, so it is worth looking at it now and then.

Skip the Notepad dance.

Free, open source, no account, no ads, no telemetry. Setting up a kid’s PC? See the parental controls. Want something lighter? HOTS Hosts Lite.