How to Edit a Host File in Windows 10 | Simple Step Guide

To edit a host file in Windows 10, open Notepad as Administrator, load the hosts file from the system etc folder, add your entries in the IP hostname format, and save.

Knowing how to edit a host file in Windows 10 gives you direct control over how your computer resolves domain names without relying on a remote server. This is useful for blocking distracting websites, mapping custom domains for local development, or overriding IP addresses for testing. The process is handled entirely through Notepad, but you must run it with elevated permissions to save changes to this protected system file.

What Is the Hosts File and Why Edit It?

The hosts file is a plain-text system file that maps hostnames to IP addresses. When you type a web address into your browser, Windows checks this file before contacting a remote DNS server. This lets you bypass normal internet DNS resolution locally. A standard entry looks like 127.0.0.1 www.example.com, which tells Windows to redirect requests for that domain back to your own machine.

How to Edit the Hosts File in Windows 10

The only reliable way to edit the file is with administrator privileges. A regular user account cannot save changes back to the original location. Follow these steps exactly to avoid common errors.

  1. Press the Windows key and type “Notepad.” Right-click the Notepad result and select Run as administrator. Click Yes when prompted by User Account Control.
  2. In the blank Notepad window, click File > Open. Navigate to the exact path: C:\Windows\System32\Drivers\etc.
  3. In the lower-right corner of the Open dialog, change the file type filter from Text Documents (*.txt) to All Files (*.*). The hosts file has no file extension, so it will not appear until you change this filter.
  4. Select the hosts file from the list and click Open.
  5. Scroll to the bottom of the file and add your entry using the format IP_address hostname. For example, to block a site, add 127.0.0.1 www.example.com. Separate the IP address and hostname with a space or tab, and place each entry on its own line.
  6. Click File > Save to write your changes directly to the hosts file. If the save succeeds without an error, the edit was applied correctly.

If you do not have Administrator rights on your Windows 10 machine, you will need to contact your IT department, because standard user accounts cannot modify the hosts file. Many public computers and school-issued devices intentionally lock this file.

Common Hosts File Entries at a Glance

The table below shows the syntax and purpose of the most common host file modifications. Use these patterns as a starting point for your own edits.

Entry Syntax Purpose Result
127.0.0.1 example.com Redirects the domain to your local machine The site fails to load from that domain
0.0.0.0 ads.com Null-routes the domain Requests to that domain time out instantly
192.168.1.10 dev.local Maps a custom hostname to a local server Browser shows your local site when you type dev.local
203.0.113.50 intranet.company.com Points a public name to an internal IP Workers resolve local apps without public DNS
# 127.0.0.1 disabled.site.com Comments out an entry with a hash The line is ignored and the normal DNS is used
127.0.0.1 localhost Default localhost resoluton Stays in file by default; do not remove
::1 localhost IPv6 localhost resolution Stays in file by default; do not remove

The format is strict. Add a space or tab between the IP address and the hostname. Do not add extra dots or characters. Microsoft’s official documentation spells out this exact format on their Windows support page for editing the hosts file.

Why Does the Save Fail on My First Try?

The most common mistake is opening the file without administrative rights. When you open Notepad normally, it runs in user mode. User-mode applications cannot write to files in the System32 folder. The fix is to close Notepad, right-click the application from the Start menu, and choose Run as administrator.

The second most common mistake is the file filter. By default, Notepad’s Open dialog only shows Text Documents (*.txt). Because the hosts file has no extension, it is invisible until you switch to All Files (*.*) at the bottom right of the dialog. If you cannot see the file, this filter is the cause.

Troubleshooting Hosts File Edits

Below are the most frequent problems people run into and how to fix them.

Problem Likely Cause Solution
The hosts file is not visible Open dialog is filtered to .txt files Change filter to All Files (*.*)
“Access Denied” on save Notepad was not launched as administrator Reopen Notepad and select Run as administrator
Changes do not take effect DNS cache is holding the old mapping Open Command Prompt (Admin) and run ipconfig /flushdns
The wrong site loads instead Typo in the IP address or hostname Check for extra spaces or missing dots in your entry
Entry keeps coming back Antivirus or security software is restoring it Add an exclusion in your security software for the hosts file

After editing the hosts file, some applications keep their own DNS cache. Browsers like Chrome and Edge have internal DNS caches. Full resolve of the issue often requires flushing Windows DNS cache via ipconfig /flushdns in an elevated Command Prompt.

Know Before You Edit

Editing the Windows 10 hosts file is straightforard when you follow the correct process. The keysteps are: launch Notepad as Administrator, navigate to the exact file path C:\Windows\System32\Drivers\etc\hosts, add your rules in IP hostname format, and save directly back. Always test your changes by trying to access the domain you modified. The hosts file is a local override, so changes affect only the machine you edit, and incorrect entries can break site access until you remove them. Keep a backup of the original file if you plan to make many edits.

References & Sources