🪟 Windows TippsModify Windows Support Phone Number with PowerShell(03.09.2026 um 00:00 Uhr)
🔧 AI Nachrichten Podcast: ChatGPT schwatzt Nutzern in Deutschland jetzt Werbung auf(28.08.2026 um 08:46 Uhr)
🪟 Windows TippsMicrosoft bringt Emoji 17.0 auf Windows 11(31.08.2026 um 08:16 Uhr)
🪟 Windows TippsModify Windows Support Phone Number with PowerShell(03.09.2026 um 00:00 Uhr)
🔧 AI Nachrichten Podcast: ChatGPT schwatzt Nutzern in Deutschland jetzt Werbung auf(28.08.2026 um 08:46 Uhr)
🪟 Windows TippsMicrosoft bringt Emoji 17.0 auf Windows 11(31.08.2026 um 08:16 Uhr)

🔧 Programmierung 🕛 vor 1 Monat 2 Min Lesezeit
0

How to block websites with the hosts file

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

You can block a domain on your machine without installing another browser extension.



Point the hostname at a dead address in the hosts file. The OS resolves it locally and the site never loads.



This is blunt. It works for distraction sites, telemetry hosts you do not need, and quick local tests.






The pattern






CODE
0.0.0.0   www.example.com
0.0.0.0 example.com






0.0.0.0 is the usual choice. Some people use 127.0.0.1. Both stop the real site from loading. 0.0.0.0 avoids sending traffic to a local server you might already run.



Block both apex and www if the site uses both.






macOS and Linux



Edit hosts:




CODE
sudo nano /etc/hosts






Add your lines, save, then flush DNS:




CODE
# macOS
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

# Linux (systemd-resolved)
sudo resolvectl flush-caches









Windows



Open Notepad as Administrator, open:




CODE
C:\Windows\System32\drivers\etc\hosts






Add the same style of lines, save, then:




CODE
ipconfig /flushdns









Verify






CODE
ping -c 1 www.example.com






You should see 0.0.0.0 or a failed route, not the real public IP.



Browser still loading the site? Quit it fully and reopen. Chrome also has its own DNS cache under chrome://net-internals/#dns.






What this does not block




  • Apps that hardcode IPs

  • Sites reached through a VPN or proxy that ignores your hosts file

  • HTTPS hosts you only blocked under the wrong name (example.com vs www vs a CDN host)

  • Mobile apps on another device (hosts is local to that machine)



For team-wide or network-wide blocking you need DNS or firewall rules, not a laptop hosts file.






Keep it tidy



Group blocks under a comment:




CODE
# focus mode
0.0.0.0 www.reddit.com
0.0.0.0 reddit.com
0.0.0.0 www.youtube.com
0.0.0.0 youtube.com






When you need the site again, comment the lines or delete them and flush DNS.






Safety note



Do not block domains your OS or package manager needs unless you know what you are doing. A bad block looks like "the internet is broken" until you remember last night's edit.



Start with one domain, verify, then add more.






If you switch hosts a lot, a small desktop manager helps keep profiles and DNS flush in one place: Locahl.

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
1 Quelle
Modify Windows Support Phone Number with PowerShell
1 Quelle
Die Zukunft des Einkaufens: Warum wir ein neues Kapitel aufschlagen (und wie du es mitschreiben kannst)
1 Quelle
ZDE Podcast 251: Wie sieht digitales Instore Marketing 2026 aus, Amit Chatterjee?
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten How to block websites with the hosts file

Thematisch verwandte Begriffe: block, websites, with, hosts · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...