How to Edit the Hosts File on Windows 10 (2026)
Edit the Windows 10 hosts file step by step: Notepad as administrator, file location, UAC, save errors, DNS flush, and troubleshooting access denied.
Locahl Team
Table of Contents
- Where is the hosts file on Windows 10?
- Step-by-step: Notepad as administrator
- Step 1: Open Notepad with admin rights
- Step 2: Open the hosts file
- Step 3: Add your entry
- Step 4: Save
- Step 5: Flush DNS cache
- Verify your changes work
- Test with ping
- Test in browser
- Default Windows 10 hosts file
- Common problems on Windows 10
- Access denied when saving
- Hosts file not visible in Open dialog
- Changes saved but site still resolves to old IP
- File reverts after reboot
- Cannot ping the domain but browser works (or vice versa)
- Alternative editors on Windows 10
- Hosts file syntax reminder
- Windows 10 vs Windows 11
- IIS and local development on Windows 10
- Windows 10 Enterprise and domain-joined machines
- Automating hosts entries on Windows 10
- Best practices for Windows developers
- Related guides
Editing the hosts file on Windows 10 is straightforward once you know two things: the exact file path and that you must run your editor as administrator. This guide walks through the complete process, common errors, and verification steps.
For the cross-platform overview see How to edit the host file on all platforms.
Where is the hosts file on Windows 10?
C:\Windows\System32\drivers\etc\hostsKey facts:
- No file extension β the file is named
hosts, nothosts.txt - Protected location β inside System32, requires admin write access
- Plain text β editable with any text editor opened as administrator
- Same path on Windows 11 β location unchanged since Windows XP
You can navigate there in File Explorer, but you cannot save changes without administrator privileges.
Step-by-step: Notepad as administrator
Step 1: Open Notepad with admin rights
1. Press the Windows key 2. Type Notepad 3. Right-click Notepad in the search results 4. Click Run as administrator 5. Click Yes on the User Account Control (UAC) prompt
Important: Clicking Notepad normally (without "Run as administrator") will let you open the file but not save changes.
Step 2: Open the hosts file
1. In Notepad: File β Open (or Ctrl+O) 2. Navigate to: C:\Windows\System32\drivers\etc 3. At the bottom-right, change **"Text Documents (*.txt)" to "All Files (*.*)" 4. Select hosts (no extension visible) 5. Click Open**
If the etc folder appears empty, you forgot to change the file type filter.
Step 3: Add your entry
Scroll to the bottom and add a new line. Format:
IP_address domain_nameExample for local development:
# My Laravel project
127.0.0.1 myapp.test
127.0.0.1 api.myapp.testExample for staging override:
# Temporary - remove after migration
203.0.113.50 www.client-site.comUse spaces or tabs between the IP and domain β at least one separator is required.
Step 4: Save
Press Ctrl+S or File β Save.
Success: No error message, file closes normally.
Failure β "Access is denied": You did not open Notepad as administrator. Close Notepad completely and restart from Step 1.
Step 5: Flush DNS cache
Open Command Prompt as administrator:
1. Press Windows key, type cmd 2. Right-click Command Prompt β Run as administrator 3. Run:
ipconfig /flushdnsExpected output:
Successfully flushed the DNS Resolver Cache.Verify your changes work
Test with ping
ping myapp.testExpected:
Pinging myapp.test [127.0.0.1] with 32 bytes of data:Test in browser
Open http://myapp.test in your browser. If your local server is running on port 80, the page should load.
If using a non-standard port (e.g., 8000), the hosts file still works β you just need http://myapp.test:8000.
Default Windows 10 hosts file
A fresh Windows 10 install typically contains:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names.
127.0.0.1 localhost
::1 localhostDo not remove the localhost entries β other applications depend on them.
Common problems on Windows 10
Access denied when saving
Cause: Notepad opened without admin rights.
Fix: Close Notepad. Right-click β Run as administrator. See Edit hosts file as administrator.
Hosts file not visible in Open dialog
Cause: File type filter set to "Text Documents (*.txt)".
Fix: Change dropdown to "All Files (*.*)".
Changes saved but site still resolves to old IP
Causes and fixes:
1. DNS cache not flushed β ipconfig /flushdns 2. Browser DNS cache β Chrome: chrome://net-internals/#dns β Clear host cache 3. VPN or custom DNS (1.1.1.1, 8.8.8.8) bypassing hosts file on some Windows builds 4. Antivirus restoring the file β check security software logs
File reverts after reboot
Some "PC optimization" or security tools reset the hosts file. Check:
- Malwarebytes host shield
- Spybot Search & Destroy immunization
- Corporate group policy restrictions
Cannot ping the domain but browser works (or vice versa)
Windows 10 uses different resolution paths for ping vs browsers in some configurations. Always flush DNS and clear browser cache together.
Alternative editors on Windows 10
| Editor | How to open as admin |
|---|---|
| Notepad | Right-click β Run as administrator |
| VS Code | Right-click VS Code β Run as administrator, then open file |
| PowerShell | See [[edit-hosts-file-windows-11 |
| Hosts file GUI | Locahl or SwitchHosts β no manual admin steps |
Hosts file syntax reminder
127.0.0.1 domain.test # IPv4
::1 domain.test # IPv6
0.0.0.0 blocked-site.com # Block domain
# This is a commentFull syntax rules: Hosts file syntax guide.
Windows 10 vs Windows 11
The hosts file location, syntax, and Notepad method are identical on Windows 10 and Windows 11. Windows 11 adds a redesigned Start menu and Settings app, but the underlying process is unchanged.
For Windows 11-specific methods (including PowerShell and Settings shortcuts) see Edit hosts file on Windows 11.
IIS and local development on Windows 10
If you run IIS, WAMP, XAMPP, or Laragon on Windows 10, the hosts file pairs naturally with local site bindings:
1. Configure your web server to respond to myapp.test on port 80 or 443 2. Add 127.0.0.1 myapp.test to the hosts file 3. Flush DNS and browse to http://myapp.test
For HTTPS local development, combine hosts entries with a tool like mkcert to generate trusted local certificates. The hosts file handles name resolution; your certificate tool handles TLS trust.
Windows 10 Enterprise and domain-joined machines
On Active Directory domain-joined PCs, Group Policy may restrict hosts file editing. Symptoms include saves that appear successful but revert on next login, or GPO-deployed hosts templates that merge with local entries unpredictably.
If you are on a managed machine:
- Check with IT before adding entries
- Document business justification for staging overrides
- Never bypass corporate security policy β use an approved dev VM instead
Automating hosts entries on Windows 10
Developers who frequently add/remove entries can script the workflow:
# Add entry if missing (run as admin)
$entry = "127.0.0.1 myapp.test"
$hosts = "C:\Windows\System32\drivers\etc\hosts"
if (-not (Select-String -Path $hosts -Pattern "myapp.test" -Quiet)) {
Add-Content -Path $hosts -Value $entry
ipconfig /flushdns
Write-Host "Added: $entry"
}Pair this with a removal script for teardown. Idempotent scripts prevent duplicate lines that cause confusing resolution behavior.
Best practices for Windows developers
- Use `.test` TLD for local domains β avoids conflicts with real domains
- Comment every entry β future you will thank present you
- Back up before bulk imports β copy
hoststohosts.backup - Remove staging overrides after migration β stale entries cause hard-to-debug issues
- Flush DNS after every edit β make it a habit, not an afterthought
- Document team entries β share a standard hosts snippet in your project README
- Pin an admin Terminal shortcut if you edit hosts weekly or more
Example team snippet:
# === Project Alpha (all devs) ===
127.0.0.1 app.alpha.test
127.0.0.1 api.alpha.test
127.0.0.1 admin.alpha.testRelated guides
- Main guide β all platforms
- Windows 11 β three methods
- Administrator rights explained
- Block a website with hosts file
- Is editing the hosts file safe?
- Complete hosts file reference
---
*Last tested: Windows 10 22H2 β June 2026.*
Ready to simplify your workflow?
Stop wasting time with the terminal. Locahl lets you manage your hosts file in a few clicks, with automatic validation and no risk of errors.
- Intuitive visual interface
- Automatic DNS flush
- Multi-environment management
- Automatic backups
- JSON Import/Export
Reader Reviews
"The "All Files" filter tip was the missing piece. I could never find the hosts file in Notepad before."
June 3, 2026
"Clear Windows 10 guide. Fixed my local Laravel dev setup in under five minutes."
June 7, 2026
"Solid walkthrough. The DNS flush section should be bolded β I wasted an hour without it."
June 9, 2026
Frequently Asked Questions
Where is the hosts file on Windows 10?
C:\Windows\System32\drivers\etc\hosts β a plain text file with no extension, protected by administrator permissions.
Why does Notepad say Access Denied when saving?
You opened Notepad without administrator privileges. Close it, right-click Notepad, choose Run as administrator, then reopen the file.
How do I flush DNS on Windows 10?
Open Command Prompt or PowerShell as administrator and run: ipconfig /flushdns
Can I edit the hosts file without Notepad?
Yes. You can use PowerShell, VS Code (as admin), or a dedicated hosts file editor. See [[edit-hosts-file-windows-11|Windows 11 guide]] for alternative methods.
Does Windows 10 Defender block hosts file edits?
Windows Defender does not block legitimate hosts file edits. Some third-party security suites may restore the file β check your antivirus settings if changes revert.
What is the default Windows 10 hosts file content?
Typically: 127.0.0.1 localhost, ::1 localhost, and a few commented Microsoft examples. Do not delete the localhost entries.
Related Articles
How to Edit the Hosts File on Windows 11 (2026)
Three methods to edit the Windows 11 hosts file: Notepad as admin, PowerShell, and VS Code. Includes UAC tips, DNS flush, and troubleshooting for 24H2.
Locahl Team
Edit the hosts file on Mac: Terminal vs GUI (2026)
How to edit /etc/hosts on macOS without errors? Terminal (sudo nano) vs GUI comparison. Fix permission denied and DNS cache issues in 2 minutes.
Locahl Team
Hosts File: Location, Syntax and Uses (2026)
Learn what the hosts file does, where to find it on Mac, Windows and Linux, syntax examples, local dev uses and mistakes to avoid.
Locahl Team
How to Edit the Host File on Windows, Mac and Linux (2026)
Edit the host file on Windows, macOS and Linux: file location, admin rights, syntax, DNS flush, and troubleshooting when changes do not apply.
Locahl Team
How to Edit the Hosts File on Linux (2026)
Edit /etc/hosts on Linux with nano or vim: permissions, syntax, DNS flush on systemd and legacy systems, and troubleshooting for developers.
Locahl Team