NETWORK FIX Target: Windows 11 & 10 • Location: drivers\etc\hosts
Windows Networking & Troubleshooting Guide

How to Edit Hosts File in Windows 11 & Fix "Access Denied"

Quick Answer (30-Second Solution)
To fix "Access Denied" when saving the hosts file, launch Notepad as Administrator (Win + S > Notepad > Run as Administrator), open C:\Windows\System32\drivers\etc\hosts, edit your rules, and save. To eliminate permission errors forever, toggle entries, and auto-flush DNS in 1-click, use the free 57 KB Pexoris Hosts Manager.

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:

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:

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.