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. Checked against Microsoft Support on September 27, 2026.
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.
Find the hosts file
- Open File Explorer.
- Click in the address bar, type
%WinDir%\System32\drivers\etc, and press Enter. - The file is called hosts. It has no file extension, so it may show as a “File” type. See how to show file extensions in Windows 10.
Edit the hosts file
- Select Start and type Notepad. Right-click Notepad and select Run as administrator. Select Yes if Windows asks.

- Select File > Open. In File name, type
C:\Windows\System32\drivers\etc\hostsand select Open. - 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

- Select File > Save.
- To use the change right away, open Command Prompt and run
ipconfig /flushdns. See how to open Command Prompt in Windows 10.
To undo an entry, delete its line, or type # at the start of it, and save again.
Reset the hosts file to the default
Microsoft’s steps are:
- In Notepad, paste the default text from Microsoft’s page and save it on your desktop as
"hosts"(with the quotes), with Save as type set to All files (*.*). - In the
%WinDir%\System32\drivers\etcfolder, rename the old file to hosts.old. - 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.
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, see how to change DNS in Windows 10.
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 with Microsoft’s default text shown above.
To use the hosts file to block a site, see how to block a website in Windows 10.
Some apps keep their settings in a similar text file. See how to create an INI file in Windows 10.
Microsoft’s references are How to reset the Hosts file back to the default and ipconfig. More help is on our Windows Help & Guides page.
Related: how to edit the hosts file in Windows 11.

Matt Jacobs has been working as an IT consultant for small businesses since receiving his Master’s degree in 2003. While he still does some consulting work, his primary focus now is on creating technology support content for SupportYourTech.com.
His work can be found on many websites and focuses on topics such as Microsoft Office, Apple devices, Android devices, Photoshop, and more.