How to block a website or domain on Windows
Updated
Short answer
The built-in way is the hosts file: add a line such as 0.0.0.0 example.com to C:\Windows\System32\drivers\etc\hosts as administrator. It has no wildcards, so every subdomain needs its own line. A domain-aware firewall such as PacketShield blocks example.com or *.example.com for every app and keeps the rule updated when the site’s IP addresses change.
Option 1: the hosts file
- Open Notepad as administrator (search Notepad, right-click › Run as administrator).
- Open C:\Windows\System32\drivers\etc\hosts (choose “All files” in the open dialog).
- Add one line per domain, as shown below, and save.
- Run ipconfig /flushdns so cached lookups are cleared.
0.0.0.0 example.com
0.0.0.0 www.example.comLimits: no wildcards (blocking *.example.com is not possible), each subdomain must be listed, and apps that use their own DNS resolver can skip the hosts file.
Why not a Windows Firewall rule?
Windows Firewall rules match IP addresses, not domain names. Most websites sit behind CDNs whose addresses are shared and change often, so an IP rule either stops working or blocks other sites by accident.
With PacketShield: block by domain or wildcard
- Open PacketShield and click Block Domain (or use the Rules screen).
- Type the domain (example.com) or a wildcard (*.example.com).
- Save. PacketShield resolves the domain, creates the firewall rules and keeps them updated as the addresses change.
The block applies to every app on the computer, not just the browser. A wildcard counts as a single rule, so even the free version (1 block rule) can block a whole family of subdomains.
Frequently asked questions
Can the hosts file block all subdomains with a wildcard?
No. The hosts file has no wildcard support; you have to list each subdomain. A domain-aware firewall can block *.example.com.
Does blocking a domain work in every browser?
A firewall-level block applies to all apps, including every browser. Browser extensions only work inside the browser they are installed in.
Will the block stop working when the site changes IP?
A plain IP rule would. PacketShield re-resolves blocked domains and updates its rules, so the block follows the site.