How to Find and Edit the Hosts File in Windows 10

The hosts file in Windows 10 is at C:\Windows\System32\drivers\etc\hosts. To edit it, select Start, type Notepad, right-click Notepad, and select Run as administrator. Then select File > Open, open the hosts file, add a line with an IP address and a name, and select File > Save.

Applies to: Windows 10. Windows 10 reached end of support on October 14, 2025, and only PCs enrolled in Extended Security Updates still get security fixes, through October 12, 2027.

The hosts file is a plain text file that matches names, like contoso-nas, to IP addresses. Windows uses it before asking the internet (DNS), so an entry here overrides the usual address. Lines that start with # are notes, and Windows ignores them. Web developers use it too: pointing a name such as testsite.local to 127.0.0.1 lets you open a local site by name after you enable IIS in Windows 10 and give the site that host name.

Find the hosts file

  1. Open File Explorer.
  2. Click in the address bar, type %WinDir%\System32\drivers\etc, and press Enter.
  3. The file is called hosts. It has no file extension, so it may show as a “File” type. Turning on file extensions in Windows 10 makes this easier to see.

Edit the hosts file

  1. Select Start and type Notepad. Right-click Notepad and select Run as administrator. Select Yes if Windows asks.
Windows 10 Start menu search for Notepad with Run as administrator highlighted
Right-click Notepad and select Run as administrator (1).
  1. Select File > Open. In File name, type C:\Windows\System32\drivers\etc\hosts and select Open.
  2. Go to the end of the file and add a new line: the IP address, a space, and the name. For example:

192.168.1.50 contoso-nas

Windows 10 Notepad running as administrator with the hosts file open and a new entry added at the end
Add your entry on its own line at the end (1).
  1. Select File > Save.
  2. To use the change right away, open Command Prompt and run ipconfig /flushdns.

To undo an entry, delete its line, or type # at the start of it, and save again.

Reset the hosts file to the default

To put back the original file:

  1. In Notepad, paste the default text from Microsoft’s reset page (linked at the end of this article) and save it on your desktop as "hosts" (with the quotes), with Save as type set to All files (*.*).
  2. In the %WinDir%\System32\drivers\etc folder, rename the old file to hosts.old.
  3. Move the new hosts file from your desktop into the etc folder, and select Continue if Windows asks.

Stay safe

  • Only add entries you understand. A wrong entry can stop a website or network device from opening.
  • If you find entries you didn’t add, remove them and run a scan in Windows Security.
  • Some security apps protect the hosts file and undo changes to it.

If saving or using the hosts file fails

  • Save still fails as administrator. The file may be marked read-only. In File Explorer, right-click hosts, select Properties, clear Read-only, and select OK.
  • Windows Security warns about the hosts file. Blocking some Microsoft addresses can be flagged as a threat named SettingsModifier:Win32/HostsFileHijack. If you made the change yourself on purpose, you can allow it in Protection history. If you didn’t, let Windows Security remove it.
  • A VPN or proxy ignores your entries. Some VPNs and proxy apps handle name lookups themselves. Disconnect them to test your hosts file.
  • An entry is ignored. Each entry needs the IP address first, then at least one space, then the name, on its own line. Remove any # at the start of the line.
  • A blocked site still opens in the browser. Browsers keep their own short-term DNS cache, so close every browser window and open it again after ipconfig /flushdns. Also add a separate line for each version of the name, such as example.com and www.example.com, because the hosts file doesn’t cover subdomains.

Frequently asked questions

Why do I get “Access denied” when I save?

Notepad isn’t running as an administrator. Close it and start again from step 1.

Why doesn’t my change work?

Make sure the file is still named hosts, not hosts.txt. Then run ipconfig /flushdns and restart your browser.

Should I edit the hosts file or change my DNS?

The hosts file is for a few names on one PC. To change where the whole PC looks up addresses, change the DNS server instead.

Can I add more than one name for the same address?

Yes. Put them on one line after the IP address, separated by spaces, such as 192.168.1.20 nas nas.home.

Should I make a copy before editing?

Yes. Copy hosts to your Documents folder first. If something stops working, copy it back as administrator, or reset it to the default as described above.

A common use for the hosts file is to block a website in Windows 10. On a newer PC, editing the hosts file in Windows 11 works much the same way.

Microsoft’s references are How to reset the Hosts file back to the default and ipconfig.