A community-maintained list of YouTube ad-serving domains β add one link to Pi-hole and you're done.
Last updated: Sept 21st 2026 - 15,901 domains in the list - works with Pi-hole v5 and v6, AdGuard Home, pfBlockerNG, Technitium and any other DNS blocker that accepts a hosts-style domain list.
- Option 1 Β· Add the list to Pi-hole (recommended)
- Option 2 Β· Run the script
- Other DNS blockers (AdGuard Home, pfBlockerNG, Technitium, Blocky)
- What it does and doesn't do
- How it works
- The crowd list (optional)
- Troubleshooting
- Privacy
- Contributing
- Support the project
The easiest way β nothing to install. Pi-hole downloads the list itself and refreshes it every time gravity updates.
- Open the Pi-hole web interface β Lists (Pi-hole v6) or Group Management β Adlists (Pi-hole v5).
- Paste this address into the Address field and click Add:
https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/refs/heads/master/youtubelist.txt - Update gravity so the list takes effect: Tools β Update Gravity, or from the terminal:
pihole -g
That's it. Pi-hole re-downloads the list on every gravity update (weekly by default β run pihole -g any time to get the latest version sooner). The published list already excludes everything in ignore.list, so videos keep playing.
π‘ Using Pi-hole's default blocklist (StevenBlack hosts)? It blocks
s.youtube.com, which breaks video playback. Allow it once:pihole allow s.youtube.com # Pi-hole v6 pihole -w s.youtube.com # Pi-hole v5
Prefer to have every domain as an exact entry in your denylist (visible under Domains in the web interface), add your own never-block entries, or pick up new domains every hour instead of at the next gravity update? Use youtube.sh.
Every time it runs it:
- downloads the latest
black.listfrom this repo, - drops everything that matches
ignore.list(so videos keep playing), - adds only the domains your Pi-hole doesn't have yet β the first run takes a few minutes, later runs finish in seconds,
- reloads Pi-hole's lists so the new domains are blocked right away.
It works with Pi-hole v5 and v6, needs nothing beyond what Pi-hole already installs, and re-runs itself with sudo if you forget.
git clone https://github.com/kboghdady/youTube_ads_4_pi-hole.git
cd youTube_ads_4_pi-hole
sudo ./youtube.shYou should see something like:
YouTube ads blocker for Pi-hole v6
[i] Downloading the latest YouTube ad list...
[+] 15855 domains in the list (0 skipped because of ignore.list)
[i] Adding 15855 new domain(s) to the denylist...
[i] This takes a few minutes the first time - later runs only add what is new
................................................................................
[+] Added 15855 domain(s)
[i] Reloading Pi-hole's lists...
[+] Shared 12 googlevideo.com hostname(s) from your query log - thank you!
[+] All done. Pi-hole is blocking 15855 YouTube ad domains.
Add the script to root's crontab so it picks up new domains on its own:
sudo crontab -eAdd this line to run it every hour (change the path if you cloned somewhere else):
0 * * * * /home/pi/youTube_ads_4_pi-hole/youtube.sh > /dev/null 2>&1
Tip: crontab.guru explains the schedule syntax if you'd like a different interval.
| Option | What it does |
|---|---|
--dry-run |
Show what would change without touching Pi-hole β great for a first look |
--no-share |
Don't send googlevideo.com hostnames from your query log (see Privacy) |
--crowd |
Also block the unfiltered crowd list (see The crowd list) |
-h, --help |
Show the help text |
The same settings live at the top of youtube.sh if you'd rather change them permanently.
To add your own never-block entries, put them in the ignore.list next to the script (one per line β a full hostname or just a part of it, such as n4v7sne7). Your entries are merged with the latest ignore.list from this repo on every run.
youtubelist.txt is a plain list of hostnames, one per line, so it works with any DNS-level ad blocker that can subscribe to a domain list β not only Pi-hole. Use the same address everywhere:
https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/refs/heads/master/youtubelist.txt
| Blocker | Where to add it |
|---|---|
| AdGuard Home | Filters β DNS blocklists β Add blocklist β Add a custom list, paste the URL |
| pfBlockerNG (pfSense) | Firewall β pfBlockerNG β DNSBL β DNSBL Groups, add a feed with the URL (format Auto) |
| Technitium DNS | Settings β Blocking β Block List URLs, add the URL |
| Blocky | Add the URL under blocking.denylists in config.yml |
| OPNsense Unbound | Services β Unbound DNS β Blocklist, add it as a custom blocklist URL |
Whatever you use, keep s.youtube.com and the hostnames in ignore.list allowed β they are needed for videos to play.
It does
- Block the DNS lookups for known YouTube ad-serving hostnames, network-wide, on every device that uses your DNS server β smart TVs, phones, consoles and browsers alike, with nothing to install on them.
- Stop many pre-roll and mid-roll video ads from loading at all, instead of showing a skippable ad.
- Stay current: the list is refreshed every day or two from the hostnames users report (see Privacy).
It doesn't
- Block every ad. YouTube serves ads and videos from the same
googlevideo.comdomains and rotates them constantly; some ads will always slip through, and new hostnames take a day or two to reach the list. - Block ads that are stitched into the video stream itself (server-side ad insertion). No DNS blocker can β that needs a browser extension such as uBlock Origin or SponsorBlock on the device.
- Remove sponsor segments, banners, or ads inside the YouTube app on devices that bypass your DNS (for example, with DNS-over-HTTPS enabled or a hard-coded DNS server).
- Track you. Option 1 sends nothing anywhere; Option 2 shares only the hostnames described under Privacy, and you can turn that off.
For the best result, use this list on your DNS blocker and a browser extension on the devices where you can install one.
YouTube serves ads and videos from the same family of domains (*.googlevideo.com), so a normal blocklist can't tell them apart. This project keeps a curated list of the hostnames that only serve ads, and an ignore.list of the ones that break video playback. Both published lists are filtered against ignore.list before every update.
| File | What it is |
|---|---|
youtubelist.txt |
The list to add to Pi-hole (Option 1) |
black.list |
The same list, downloaded by youtube.sh (Option 2) |
ignore.list |
Hostnames (or parts of them) that must never be blocked because they break videos |
crowed_list.txt |
Raw, unfiltered domains gathered from the community β see The crowd list |
youtube.sh |
The script behind Option 2 |
The list is refreshed every day or two.
crowed_list.txt contains every googlevideo.com hostname reported by users of the script β including the ones that serve videos. It blocks more ads but is far more likely to break playback.
- As a Pi-hole list:
https://raw.githubusercontent.com/kboghdady/youTube_ads_4_pi-hole/refs/heads/master/crowed_list.txt - With the script:
sudo ./youtube.sh --crowd(or setINCLUDE_CROWD_LIST=trueat the top of the script)
Only use it if you know how to find and allow a blocked hostname in Pi-hole's query log.
Videos won't play, keep buffering or YouTube reloads in a loop
- Make sure
s.youtube.comisn't blocked. Pi-hole's default list (StevenBlack hosts) includes it, and blocking it breaks playback:pihole allow s.youtube.com # Pi-hole v6 pihole -w s.youtube.com # Pi-hole v5
- Get the latest list. Run
pihole -g(Option 1) orsudo ./youtube.sh(Option 2) β the hostname may already have been removed from the list. - Find the culprit. Open the Pi-hole query log while the video fails and look for a blocked
r?---sn-xxxxxxx.googlevideo.comentry. Allow it in Pi-hole, then please open an issue or a pull request adding thesn-xxxxxxxpart toignore.listso everyone benefits. Script users can also add it to their localignore.listand runsudo ./youtube.shagain β it removes the domain from the denylist for you.
Remove everything the script added
pihole-FTL sqlite3 /etc/pihole/gravity.db "DELETE FROM domainlist WHERE type = 1 AND domain LIKE '%googlevideo.com';"
pihole reloadlists # Pi-hole v6
pihole restartdns reload-lists # Pi-hole v5If you also want the other ad domains gone (doubleclick.net, googlesyndication.com, β¦), delete by the comment the script writes instead:
pihole-FTL sqlite3 /etc/pihole/gravity.db "DELETE FROM domainlist WHERE comment = 'YouTube ads (youtube.sh)';""The 'pihole' command was not found"
The script has to run on the machine (or in the container) where Pi-hole is installed β it talks to Pi-hole through the pihole command. If Pi-hole runs in Docker, use Option 1 instead.
Nothing happens when cron runs the script
- Use root's crontab (
sudo crontab -e), not your user's. - Use the full path to the script, e.g.
/home/pi/youTube_ads_4_pi-hole/youtube.sh. - Run it by hand once with
sudo ./youtube.shto see any error messages.
Option 1 sends nothing anywhere β Pi-hole just downloads a text file from GitHub.
To keep the list up to date, the script (Option 2) shares the googlevideo.com hostnames that your Pi-hole has seen in the last 24 hours. That's all it sends β no IP addresses, no client names, no other domains. The hostnames are collected through a Google Form and reviewed before anything is added to the list.
Don't want to share? Run the script with --no-share, or set SHARE_LOGS=false at the top of youtube.sh. Everything else works exactly the same.
- Found an ad domain that isn't blocked? Open an issue / pull request against
youtubelist.txtandblack.listβ or run the script with log sharing on and it will reach the list. - A domain breaks video playback? Open a pull request that adds it to
ignore.list. - Something in the script or docs is unclear? Issues and pull requests are very welcome.
Keeping the list current takes daily work. If it saves you from a few ads, consider buying me a coffee:
| Coin | Address |
|---|---|
| Bitcoin | 36fD957SDWHJYYzuH2xmceJ6T2qE9vNiV4 |
| XRP | rw2ciyaNshpHe7bCHo4bRWq6pqqynnWKQg |
Thank you! π
