To block a website on Windows 10 for every browser, edit the hosts file: open Notepad as administrator, open C:\Windows\System32\drivers\etc\hosts (choose All Files in the Open dialog), add a line like 0.0.0.0 example.com and another for 0.0.0.0 www.example.com, and save. Then run ipconfig /flushdns and restart your browser. For kids’ accounts, Microsoft Family Safety content filters are easier to manage, and your router can block a site for every device on your network.
This guide covers the hosts file method step by step, Family Safety, router and DNS filtering, browser extensions, and why a blocked site might still load.
Method 1: Block a website with the hosts file
- Click Start, type Notepad, right-click it, and choose Run as administrator.
- Click File > Open, go to
C:\Windows\System32\drivers\etc, change the file type from Text Documents to All Files, and open hosts. - At the end of the file, add a line for each address you want to block, for example:
0.0.0.0 example.com 0.0.0.0 www.example.com - Click File > Save. Don’t use Save As, and make sure Notepad doesn’t add a .txt extension.
- Open Command Prompt and run
ipconfig /flushdns, then close and reopen your browser.

To unblock the site, delete the lines (or put # at the start of each) and save.
Hosts file tips
- Add every version of the address you want to block, such as m.example.com for mobile versions.
- The hosts file doesn’t support wildcards, so *.example.com won’t work.
- Some security software protects the hosts file. If you can’t save, temporarily allow the change in your antivirus.
Method 2: Use Microsoft Family Safety (for children)
- Go to Settings > Accounts > Family & other users and add a family member, or open the Microsoft Family Safety website or app.
- Select the child’s account and open Content filters.
- Turn on Filter inappropriate websites and searches, and add sites under Blocked sites.
Family Safety web filters apply in Microsoft Edge. You can block other browsers for the child’s account so they can’t get around the filter.
Method 3: Block the website on your router
Most routers have a Parental Controls, Access Control, or URL/Keyword Filtering page. Sign in to the router’s admin page (often 192.168.0.1 or 192.168.1.1) and add the site. This blocks it on every device on your network, including phones and game consoles.
Method 4: Use a filtering DNS service
Some public DNS services offer family filters that block adult or malicious sites. Set them in Settings > Network & Internet > your connection > Properties > DNS server assignment, or on your router for the whole network. Some services also let you create a custom block list with a free account.
Method 5: Use a browser extension
Site-blocker extensions for Chrome, Edge, and Firefox are handy for blocking distracting sites while you work, often with schedules. They only work in the browser where they’re installed and are easy to disable, so they’re better for self-control than parental control.
Why a blocked site still loads
- Browser DNS cache – close all browser windows and reopen them, or restart the PC.
- Secure DNS (DNS over HTTPS) – browsers with secure DNS turned on may bypass the hosts file. In Chrome or Edge settings, search for secure DNS and turn it off, or choose With your current service provider.
- Missing address variations – add both example.com and www.example.com.
- VPN or proxy – these can bypass router and DNS filters.
- File saved as hosts.txt – in File Explorer, turn on View > File name extensions and make sure the file is named just hosts.
Frequently asked questions
Why use 0.0.0.0 instead of 127.0.0.1?
Both work. 0.0.0.0 fails immediately, while 127.0.0.1 points to your own PC and can be slightly slower if nothing responds.
Does blocking a site in the hosts file affect other users?
Yes. The hosts file applies to every account on the PC.
Does this work in Windows 11?
Yes. The hosts file location and steps are the same in Windows 11.

Kermit Matthews is a freelance writer based in Philadelphia, Pennsylvania with more than a decade of experience writing technology guides. He has a Bachelor’s and Master’s degree in Computer Science and has spent much of his professional career in IT management.
He specializes in writing content about iPhones, Android devices, Microsoft Office, and many other popular applications and devices.