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.
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.
- 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.
- 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.
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\etcinto 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.
Add a comment above your changes (for example # blocked for the kids, Nov 2026) so you remember why they are there.
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 /flushdnsin 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.
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.
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.
Questions people ask
Where is the hosts file in Windows 11?
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?
Do I have to restart Windows after editing it?
ipconfig /flushdns and restart your browser.What is the difference between 127.0.0.1 and 0.0.0.0?
Can I block a whole domain with a wildcard?
How do I restore the default hosts file?
Is it safe to edit the hosts file?
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.