Edit the Windows 11 Hosts File With PowerToys or Notepad

Last updated on November 13th, 2026 at 06:44 pm

For a hosts entry in Windows 11 that is easy to switch off again, the safest route is the free PowerToys Hosts File Editor, with Notepad run as administrator as the fallback. Either way you are changing one file, C:\Windows\System32\drivers\etc\hosts, and you need administrator rights to save it. The same steps apply on version 24H2 and later whether you are testing a site on a new server, blocking a domain or naming a device on your network.

Pick a method for what you are doing

The hosts file is a plain text list that Windows checks before it asks a DNS server where a name lives. It affects only this PC. Which tool you use depends on how often you will touch it. On an older PC, the same file lets you block websites in Windows 10 for every browser.

SituationBest methodWhy
You switch test entries on and off oftenPowerToys Hosts File EditorEach line has an on/off switch, and it backs up the file before saving
One quick change, nothing extra to installNotepad as administratorBuilt in; works on any Windows 11 PC
You can approve admin prompts but Notepad will not open elevatedEdit a copy, then paste it backOnly the final copy step needs administrator approval
One line from an elevated TerminalAdd-ContentAppends without opening an editor
You already use sudo in Terminalsudo notepadOpens the file elevated from the command line
Work or school PCAsk IT firstSecurity software or policy may block the change or undo it

Add an entry with PowerToys Hosts File Editor

PowerToys is a free set of Microsoft utilities available from the Microsoft Store. Install it, then:

  1. Open PowerToys Settings, select Hosts File Editor, and make sure it is turned On.
  2. Select the PowerToys icon in the system tray (the notification area by the clock) and choose Hosts File Editor. There is no keyboard shortcut for it.
  3. Approve the User Account Control prompt and read the startup warning that editing hosts changes name resolution.
  4. Select New entry. Type the IP address, the host name, and an optional comment such as “staging server for Alex”.
  5. Turn on Active, then select Add. The change is saved to the file.

Per Microsoft’s Hosts File Editor documentation, the editor saves a backup named hosts_PowerToysBackup_ followed by the date and time in the same etc folder before the first save of each session. By default it deletes backups older than 15 days but always keeps the five most recent. To pause an entry later, just turn off its Active switch instead of deleting it. The filter icon finds entries by address, host or comment once the list grows.

Edit with Notepad when PowerToys is not an option

  1. Select Start, type Notepad, then choose Run as administrator in the search results and select Yes. If Notepad is hard to find, see the ways to open Notepad in Windows 11; other elevation shortcuts are in running apps as administrator in Windows 11.
  2. Choose File > Open, paste C:\Windows\System32\drivers\etc into the address bar, and press Enter.
  3. Change the file type list from Text documents (*.txt) to All files (*.*), select hosts, and select Open.
  4. Add your entry on a new line at the end of the file.
  5. Press Ctrl + S. If Windows says you do not have permission, or Notepad offers to save a new copy, it is not running as administrator: close it and start again from step 1.

Before your first Notepad edit, copy hosts to your Desktop as a backup. That copy also enables the paste-back method: edit the Desktop copy in normal Notepad, save it, then copy it into the etc folder, choose to replace the file, and approve the administrator prompt. If you have turned on sudo under Settings > System > Advanced, which Microsoft documents for Windows 11 24H2 and later, you can run sudo notepad C:\Windows\System32\drivers\etc\hosts from Terminal. The sudo setup for Windows 11 explains its modes.

For a single line, skip the editor. In Terminal (Admin), Add-Content -Path C:\Windows\System32\drivers\etc\hosts -Value "203.0.113.10 www.example.com" appends one line, as the Add-Content reference describes. Never use a single > redirect, which replaces the whole file; Microsoft’s redirection notes warn that it overwrites without warning.

What a Default Hosts File Looks Like

On a Windows 11 laptop, I opened Notepad, pressed Ctrl+O and opened C:\Windows\System32\drivers\etc\hosts.

Windows 11 default hosts file opened in Notepad
A default hosts file in Notepad.

Every line starts with a #, so nothing is active. New entries go on their own lines at the bottom with no # in front. A Notepad window that isn’t running as administrator can open the file but can’t save it.

Entry formats that work

Every entry is one line: an IP address, at least one space or tab, then a host name. Anything after # is a comment. Wildcards such as *.example.com are not supported, so list each name you need.

GoalExample lineNote
Preview a site on a new server before DNS moves203.0.113.10 www.example.comAdd example.com on its own line too if the site uses both
Name a NAS or printer on your network192.168.1.40 nas.homeReserve that IP in your router so the entry stays correct
Local development name127.0.0.1 shop.testPoints the name at this PC
Block a domain0.0.0.0 ads.example.net0.0.0.0 fails at once; 127.0.0.1 also works but can wait on a local web server
Pause an entry in Notepad# 203.0.113.10 www.example.comRemove the # to bring it back

To find the address of a device such as a NAS, check your router’s device list or see how to find an IP address in Windows 11.

Prove the entry is live

  1. Open Terminal and run ipconfig /flushdns so Windows drops any cached answer for that name. A restart is not needed. Details are in flushing the DNS cache in Windows 11.
  2. Run ping www.example.com. The first line should show the IP address you entered.
  3. Close every browser window, reopen the browser, and load the site.

Do not test with nslookup. It asks your DNS server directly and skips the hosts file, so it will still show the old address even when your entry works.

Why your hosts entry may not work

Ping shows my IP, but the browser still opens the real site. Why?

The browser may be using secure DNS (DNS over HTTPS), which can send lookups to an encrypted DNS provider instead of through Windows. In Edge or Chrome, type secure DNS in the settings search box and turn off Use secure DNS while you test. Also try a private window, since the browser keeps its own cache.

Could Notepad have renamed the file?

Yes, if you saved with the wrong file type, Windows now has hosts.txt and ignores it. In File Explorer, turn on View > Show > File name extensions, delete any stray copy, and make sure the real file is named hosts with no extension. While you are there, open its Properties and clear Read-only if it is checked.

What does “Failed to save hosts file” mean in PowerToys?

The editor is running without administrator rights, so it is read-only. In the editor’s settings, turn on Open as administrator (on by default), reopen it, and approve the prompt.

Will a VPN or my company’s settings override my entry?

They can. A proxy or a VPN that resolves names on its own servers sends traffic past your entry, and managed PCs often run security tools that undo hosts changes. Disconnect the VPN for a quick test; on a work PC, ask IT.

Undo a change and spot lines you did not add

  • Turn one entry off: switch off Active in PowerToys, or add # in front of the line in Notepad, then flush DNS again.
  • Roll back everything: copy your Desktop backup, or the newest hosts_PowerToysBackup_ file renamed to hosts, into the etc folder and replace the current file.
  • Know the default: a clean Windows 11 hosts file contains only comment lines, including commented examples for localhost. Active lines you do not recognize, especially ones pointing banking or update sites at odd addresses, are a warning sign. Remove them and run a full scan in Windows Security.
  • Entries keep disappearing: Microsoft Defender can flag hosts changes that redirect well-known services and restore the file. Check Windows Security > Virus & threat protection > Protection history before deciding whether to allow it.

Still on an older PC? The Windows 10 hosts file steps use the same file and syntax. Once your test is done, turn the entry off so the PC goes back to normal DNS.