Skip to content

How to block YouTube on a computer

Add a few lines to your computer's hosts file and YouTube stops loading in every browser on that computer. The tool below writes the lines and the steps for Windows, macOS or Linux. If you only need YouTube blocked in Chrome, the extension does it with one switch.

Add to ChromeComing to the Chrome Web StoreTry the tool
Drawing of two browser windows on youtube.com, the front one crossed out in red with a Blocked in every browser badge, and a hosts file card with 0.0.0.0 lines for youtube.com, www.youtube.com and youtu.be

Hosts file blocker

Your computer checks the hosts file before it asks a DNS server where a website is. Lines that point YouTube's addresses to 0.0.0.0 send those requests nowhere. Pick your system and the addresses to block, then copy the lines and follow the steps. Nothing leaves your browser.

Lines for your hosts file
Steps
  1. Open the Start menu, type Notepad, right-click it and choose Run as administrator.
  2. In Notepad choose File → Open, go to C:\Windows\System32\drivers\etc, switch the file filter to All files and open hosts.
  3. Paste the lines at the very end of the file and save.
  4. Open Command Prompt and run ipconfig /flushdns.
  5. Restart your browser. youtube.com now fails to load.

To undo: open the same file, delete the lines between the two # comments, save, and restart the browser.

Before you edit the file

  • You need administrator rights. On Windows you run Notepad as administrator. On a Mac or Linux, sudo asks for your password.
  • Anyone with administrator rights on this computer can undo the block by deleting the lines.
  • Restart the browser after the change. A browser that stays open can keep loading YouTube for a while.

Which way to choose

Hosts fileExtension switch
Blocks YouTube inEvery browser on this computerOnly the browser it's installed in (Chrome)
Admin rightsNeededNot needed
Turning it onPaste the lines, save, restart the browserOne click
Turning it offDelete the lines by handOne click, after the PIN if you set one

Maybe you only need to remove part of YouTube. If a few channels pull you in, block those channels and keep the rest. If it's one video, you can hide just that video.

Try the switch

Turn on Block all of YouTube in the demo. The feed is replaced by a blocked page until you switch it off.

Made-up channels and videos. The rules behave the way they do in the extension.

One switch: youtube.com stops opening in this browser.

Showing all 6 items. Nothing is hidden yet.

14:02

Filling my sister's garage with 5,000 paper planes

Stunt Goblins

27:41

I spent a whole night inside a furniture store

Graveyard Shift

18:40

Reacting to the weirdest gadget ever sold

Hot Take Hour

22:17

The 12-layer sandwich challenge (ASMR edition)

Snack Titans

16:08

Season finale spoiler talk: who really won?

Couch Critics

11:55

Rubber snake prank on my dad (he jumped)

Stunt Goblins

How the extension blocks all of YouTube

  1. 1

    The extension has one switch, Block all of YouTube. Turn it on and youtube.com stops opening in Chrome.

    Drawing of the YT Block panel with the Block all of YouTube switch turned on and a red pointer on it
    The Block all of YouTube switch in the YT Block panel.
  2. 2

    It needs no administrator rights and doesn't touch the hosts file or any other system file.

  3. 3

    Set a PIN and the switch asks for it before it turns off, so ending the block takes more than one click.

    Drawing of the YT Block panel asking to enter the PIN to turn off, with a red pointer on the PIN field
    The PIN prompt that comes before the switch turns off.
  4. 4

    It works only in the browser where you install it. Other browsers on the computer can still open YouTube, so use the hosts file if you need those covered too.

    Drawing of two browser windows on youtube.com: Chrome shows a YouTube is blocked page ringed in red, another browser still shows videos under a Still opens YouTube badge
    Blocked in Chrome, where the extension is; another browser still opens YouTube.

The same extension also hides channels, keywords, Shorts and recommendations, for days when you'd rather keep YouTube and drop the parts that pull you in. See the full feature list.

Questions about blocking YouTube on a computer

Does the hosts file block YouTube in every browser?

Yes, on this computer. Browsers on the computer read the same hosts file when they look up an address, so youtube.com fails to load in each of them. Phones and other computers on the same Wi-Fi are not affected.

I saved the file, but YouTube still opens. Why?

Run the command from the steps that clears the DNS cache, then close the browser completely and open it again. A browser can remember an address it looked up a moment ago. If YouTube still loads, open the file and check that the lines are there. The editor can only save it with administrator rights.

Can someone else undo the block?

Yes. Anyone with administrator rights on this computer can open the hosts file and delete the lines, the same way you added them.

Does the extension need administrator rights?

No. The Block all of YouTube switch works inside Chrome and changes nothing on the system. That also means it blocks YouTube only in Chrome. A PIN keeps the switch from being turned off with one click.

Block YouTube in Chrome with one switch

It needs no administrator rights, and a PIN keeps you from turning it off on a whim.

Coming to the Chrome Web Store

Coming to the Chrome Web Store

The extension is being finished and isn't in the store yet. Until then, the tools on this site work right here in your browser.