How to Use the Hosts File to Block Tracking Domains on Windows
Block known telemetry and ad domains locally using the Windows hosts file, with Kudu helping improve overall privacy.
By the Kudu Team
Fix this automatically with Kudu
Run a free system scan to detect and resolve this issue automatically — no manual steps required.
Download Kudu Free →What Causes This?
Windows uses the hosts file to map domain names to IP addresses before it asks DNS servers for an answer. By adding known telemetry, ad, or tracking domains to this file and pointing them to 127.0.0.1 or 0.0.0.0, you can block those connections locally on your PC. The problem is that the file is protected, easy to edit incorrectly, and some apps or updates may overwrite changes or ignore a few blocked domains if they use hardcoded IPs or encrypted DNS methods.
Common Symptoms
- Certain ads, telemetry endpoints, or tracking services stop loading
- Some apps or websites behave oddly after adding block entries
- You get an “Access denied” or “You don’t have permission” error when saving the file
- Changes do not seem to work until DNS cache is cleared
- The
hostsfile keeps getting reset or modified by another program
How to Fix It Manually
-
Open Notepad as administrator
- Click Start, type Notepad
- Right-click Notepad and choose Run as administrator
- Click Yes if Windows asks for permission
-
Open the hosts file
- In Notepad, click File > Open
- Go to:
C:\Windows\System32\drivers\etc - In the file type dropdown, change Text Documents (*.txt) to All Files
- Select hosts and click Open
-
Add tracking domains you want to block
- At the bottom of the file, add entries like these:
0.0.0.0 example-tracker.com 0.0.0.0 ads.example.com 127.0.0.1 telemetry.example.net - Use one domain per line
- Do not add
http://,https://, slashes, or extra punctuation - If you want to keep notes, start the line with
#
- At the bottom of the file, add entries like these:
-
Save the file correctly
- Click File > Save
- If you get a permission error, confirm you opened Notepad as administrator
- Make sure the file is still named hosts with no
.txtextension
-
Clear the DNS cache
- Press Win+S, type cmd
- Right-click Command Prompt and choose Run as administrator
- Run:
ipconfig /flushdns - You should see a message saying the DNS Resolver Cache was flushed
-
Test whether the block is working
- Open your browser and visit a site or app that normally contacts the blocked domain
- If needed, restart the browser or the app
- You can also test in Command Prompt with:
If the hosts entry is being used, it should resolve toping example-tracker.com127.0.0.1or fail locally
-
Undo or troubleshoot if something breaks
- Reopen the
hostsfile and remove the line you added - Save the file and run
ipconfig /flushdnsagain - If the file keeps changing, check whether a security tool, browser extension, VPN, or privacy app is managing it
- Reopen the
Manual editing works, but be careful: blocking the wrong domain can break sign-in pages, app updates, sync features, or embedded content on websites. It is best to add entries gradually and test after each change instead of pasting a huge list all at once.
Fix It Automatically with Kudu
Kudu can help detect privacy-related Windows settings, unnecessary background connections, and system issues that make manual blocking harder to manage. Instead of editing protected files by hand and troubleshooting DNS problems yourself, Kudu gives you a simpler way to improve privacy and reduce unwanted system noise safely.
Fix this automatically with Kudu
Run a free system scan to detect and resolve this issue automatically — no manual steps required.
Download Kudu Free →Related guides
How to Block Browser Extensions from Tracking in Edge, Chrome, and Firefox
Limit extension-based tracking and data collection across major browsers, and use Kudu to help identify privacy risks.
How to Block Camera Access on Windows Globally and Per App
Protect your privacy by disabling webcam access system-wide or for specific apps, with Kudu helping review permissions.
How to Block Location Access on Windows Globally and Per App
Prevent apps and Windows services from using your location data, with Kudu helping you lock down device privacy.
How to Block Microphone Access on Windows Globally and Per App
Stop unwanted apps from listening through your microphone by changing access settings, and use Kudu to help audit them.