How to Block a Website in Windows 10

To block a website on your Windows 10 PC, open Notepad as an administrator, open the hosts file in C:\Windows\System32\drivers\etc, and add a line like 0.0.0.0 www.example.com. Save the file, and the site stops loading in every browser on that PC. To unblock it, delete the line.

Applies to: Windows 10. Checked against Microsoft Support on September 27, 2026.

Block a website with the hosts file

  1. Select Start, type Notepad, right-click it, and select Run as administrator.
  2. Select File > Open, go to C:\Windows\System32\drivers\etc, change Text Documents to All Files, and open hosts.
  3. At the bottom, add one line for each site, like this:

0.0.0.0 www.example.com

  1. Add a second line without www., like 0.0.0.0 example.com, so both versions are blocked.
  2. Select File > Save.
Windows 10 Notepad editing the hosts file with two lines that block www.example.com and example.com
Add a 0.0.0.0 line for each site (1), then save the file (2).
  1. Close and reopen your browser. If the site still opens, run ipconfig /flushdns in Command Prompt.

For more about this file, see how to edit the hosts file in Windows 10.

Unblock a website you blocked

Open the hosts file the same way, delete the line for that site (or type # at the start of it), and save. Then close and reopen your browser.

Windows 10 Command Prompt showing ipconfig /flushdns and a message that the DNS Resolver Cache was flushed
If a change doesn’t show up, run ipconfig /flushdns (1) to clear the old address (2).

Block websites for a child’s account

If you want to filter websites for your kids, use Microsoft Family Safety. Its web filters work in Microsoft’s browser, and you can allow or block sites from the Family Safety website or app. See how to set up parental controls in Windows 10.

Frequently asked questions

Can I block a website on every device in my home?

Yes, many routers can block websites for the whole network. Look for Parental controls or Access control in your router’s settings.

Can I block an app from the internet instead?

Yes. See how to block an application from accessing the internet in Windows 10.

Why can’t I save the hosts file?

Notepad needs to run as an administrator. See how to run a program as administrator in Windows 10. Some security apps also protect the file.

A website is blocked at work or school. Can I unblock it?

Those blocks are set by the network’s owner. Ask your IT team or teacher if you need access.

Microsoft’s reference is Filter websites and searches using Microsoft Family Safety. More help is on our Windows Help & Guides page.

Get Our Free Newsletter

How-to guides and tech deals

You may opt out at any time.
Read our Privacy Policy