Why Does Windows Say "Access Is Denied"?
The Windows hosts file maps domain names directly to IP addresses before checking external DNS servers. Because it controls network routing for the entire operating system, it is stored in a heavily guarded system directory:
C:\Windows\System32\drivers\etc\hosts
When you double-click the file and edit it in standard Notepad, Windows prevents you from saving because:
- Standard User Integrity Token: Even if your Windows account is an Administrator, modern Windows User Account Control (UAC) runs daily applications with standard non-elevated permissions.
- Read-Only File Attribute: Many VPN clients, antivirus tools, or malware cleaners automatically lock the hosts file with the
+R(Read-Only) flag to prevent tampering. - Third-Party Antivirus Locks: Security suites like Bitdefender, Avast, or Norton monitor the hosts file in real time and block write operations.
Method 1: Manual Fix Using Notepad as Administrator
To save changes without third-party software, follow these steps:
Step 1: Open Elevated Notepad
Click your Start menu or press Win + S, type Notepad, right-click the Notepad icon, and select Run as Administrator.
Step 2: Navigate to Protected Folder
In Notepad, click File > Open (or press Ctrl + O). In the file path bar, paste:
C:\Windows\System32\drivers\etc\
In the bottom-right dropdown, change Text Documents (*.txt) to All Files (*.*) so the hosts file becomes visible, and click Open.
Step 3: Add Routing Rules
Add your custom mapping at the bottom of the file. For example, to map a local web dev project or block an ad server:
127.0.0.1 test.local
0.0.0.0 telemetry.microsoft.com
Step 4: Save & Flush DNS
Press Ctrl + S to save. Finally, open Command Prompt and run ipconfig /flushdns so Windows drops cached DNS resolutions.
Tired of Permission Denied Errors?
Pexoris Hosts Manager runs with automatic elevation, unlocks Read-Only flags, provides 1-click adblock presets, and flushes DNS instantly on save.
Download Pexoris Hosts Manager (Free • 57 KB)Method 2: Remove Read-Only Attribute via Command Prompt
If Notepad still gives an error even when running as Administrator, the file is likely marked with the Read-Only attribute. You can remove it via Command Prompt:
attrib -r C:\Windows\System32\drivers\etc\hosts
Once cleared, reopen the file in Administrator Notepad and save your changes.
How to Block Ads and Telemetry via Hosts File
Mapping known tracking and advertising domains to 0.0.0.0 (null route) completely blocks the request at the network stack before any connection is initiated:
0.0.0.0 telemetry.microsoft.com: Stops background diagnostic and event uploads.0.0.0.0 doubleclick.net: Blocks ad serving scripts system-wide across all browsers.
In Pexoris Hosts Manager, you can apply this entire curated blocklist with a single click on "🛡️ Block Ads & Telemetry".
Frequently Asked Questions
What is the difference between 127.0.0.1 and 0.0.0.0 in hosts?
127.0.0.1 points to your local machine (localhost). If you run a local web server (like Apache or Node.js), pointing a domain to 127.0.0.1 routes traffic to your local server. 0.0.0.0 is a non-routable meta-address; pointing an ad domain to 0.0.0.0 instantly drops the connection with zero timeout latency.
Why aren't my hosts file changes working in Chrome or Edge?
Modern Chromium browsers cache DNS resolutions internally and may use Secure DNS (DoH). Clear your browser's internal DNS cache at chrome://net-internals/#dns and run ipconfig /flushdns.