Free hosts file website blocker generator (Mac & Windows)
Updated December 2026
A hosts file website blocker stops distracting sites at the operating system level by mapping their domains to 127.0.0.1 and ::1. This free generator builds a complete blocklist for Mac and Windows with zero sign-up. Select categories or specific websites below, add any custom domains you want, and copy or download hosts-blocklist.txt in one click. Every entry automatically includes the root domain, www., and known mobile or redirect subdomains (such as vm.tiktok.com, old.reddit.com, and both x.com and twitter.com). Paste the output at the bottom of /etc/hosts on Mac or C:\Windows\System32\drivers\etc\hosts on Windows, then flush DNS. It blocks those domains across Chrome, Safari, Edge, and Firefox without installing any software.
1. Choose websites to block
Apex domains automatically include both root and www. entries.
2. Your generated hosts blocklist
21 host entries (42 lines with IPv4 + IPv6)
# === Focus AI Hosts File Blocklist Start === # Generated at https://www.getfocusai.com/tools/hosts-file-generator # Delete everything between Start and End to unblock. 127.0.0.1 instagram.com ::1 instagram.com 127.0.0.1 www.instagram.com ::1 www.instagram.com 127.0.0.1 m.instagram.com ::1 m.instagram.com 127.0.0.1 x.com ::1 x.com 127.0.0.1 www.x.com ::1 www.x.com 127.0.0.1 mobile.x.com ::1 mobile.x.com 127.0.0.1 twitter.com ::1 twitter.com 127.0.0.1 www.twitter.com ::1 www.twitter.com 127.0.0.1 mobile.twitter.com ::1 mobile.twitter.com 127.0.0.1 t.co ::1 t.co 127.0.0.1 reddit.com ::1 reddit.com 127.0.0.1 www.reddit.com ::1 www.reddit.com 127.0.0.1 old.reddit.com ::1 old.reddit.com 127.0.0.1 new.reddit.com ::1 new.reddit.com 127.0.0.1 m.reddit.com ::1 m.reddit.com 127.0.0.1 redd.it ::1 redd.it 127.0.0.1 tiktok.com ::1 tiktok.com 127.0.0.1 www.tiktok.com ::1 www.tiktok.com 127.0.0.1 m.tiktok.com ::1 m.tiktok.com 127.0.0.1 vm.tiktok.com ::1 vm.tiktok.com 127.0.0.1 vt.tiktok.com ::1 vt.tiktok.com # === Focus AI Hosts File Blocklist End ===
- Open Terminal (press Command + Space, type Terminal, press Enter) and run:sudo nano /etc/hosts
- Enter your Mac login password (nothing shows while typing) and press Enter.
- Scroll to the bottom using the down arrow key and paste the blocklist you copied above.
- Press Control + O, then Enter to save, then Control + X to exit.
- Flush macOS DNS cache so the block takes effect right away:sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
- Quit and reopen Chrome (or any other browser) to clear its internal DNS cache.
Tired of editing system files or turning it back off?
Focus AI blocks these in 1 click with AI context-awareness and a passcode lock you can't easily undo. Keep the YouTube tutorials and Reddit debugging threads your job needs, while feeds and Shorts stay shut. Free for 3 AI focus sessions and up to 3 always-blocked sites.
Honest limits of the hosts file (where it breaks in real life)
- No partial-site blocking: The hosts file sees domains, not pages. Blocking
youtube.comblocks both Shorts and the tutorial you need for work. Blockingreddit.comblocks debugging threads alongsider/all. - Chrome Secure DNS (DoH) bypass: If DNS-over-HTTPS is enabled in Chrome, the browser may resolve domains directly through Cloudflare or Google DNS and ignore your local hosts file unless Secure DNS is turned off.
- You still hold the keys: Any block you can add with administrator access can be deleted in 30 seconds when you are tired at 4pm. That is why people who keep re-editing their hosts file switch to a blocker with a Friend or Parent Passcode Lock.
Frequently asked questions
How does blocking websites with the hosts file work?
Your operating system checks its local hosts file before querying an external DNS server. When you map a domain like instagram.com to 127.0.0.1 (IPv4 loopback) and ::1 (IPv6 loopback), your computer points requests for that site back to itself, so the page fails to load in Chrome, Safari, Edge, and Firefox.
Why does the generator include both 127.0.0.1 and ::1?
Modern networks and browsers often resolve websites over IPv6 as well as IPv4. If you only add a 127.0.0.1 line, Chrome or Safari may still reach the site via its IPv6 address. Including ::1 closes that loophole on dual-stack connections.
Why didn't the site stay blocked in Chrome after I edited the hosts file?
Two common causes: first, Chrome caches DNS lookups internally and also supports DNS-over-HTTPS (Secure DNS), which can bypass the local hosts file. Flush your OS DNS cache, fully quit and reopen Chrome, and check Chrome Settings > Privacy and security > Security > Use secure DNS if a listed site still resolves.
Can a hosts file block only YouTube Shorts or Instagram Reels?
No. The hosts file only works at the hostname level (such as youtube.com or instagram.com). It cannot inspect URL paths like /shorts or /reels. If you want to block Shorts while keeping tutorials, or block Reels while keeping DMs, you need a context-aware browser extension like Focus AI.
How do I undo a hosts file website block?
Open /etc/hosts (Mac) or C:\Windows\System32\drivers\etc\hosts (Windows) as administrator, delete the lines between the Start and End markers, save the file, flush your DNS cache, and restart your browser.