This is a how-to guide in order to block Spotify ads. However, this will also block most apps ads as apps usually use very similar ad providers.
This guide was done with the only aim of learning.
This is valid for:
- Desktop apps
- Android apps
- iOS apps
The main idea is to modify the hosts file in a server in order redirect to our localhost (127.0.0.1) the HTTP calls to the ads urls. This way, ads can't load and apps just don't show them.
Just modify your hosts file in order to contain these lines, and the ads should be already be blocked in the server.
So if you've got a Windows PC and want to use your PC as a server that blocks these ads, once you modify the hosts file you should have already blocked the ads in your Windows Spotify application.
Depending on the server that you are running, the hosts file may be in one of the below paths:
- Linux:
/etc/hosts
- Windows:
C:\Windows\System32\drivers\etc\hosts
- OSX:
/etc/hosts
or/private/etc/hosts
The idea here is to install a proxy server in the server where you've modified the hosts file and connect your device to the proxy server. This way, your device will redirect all the traffic through the server, and the server will block the ads via the hosts file.
So install a proxy server in your server. I like Squid:
- Linux & Windows: Installers: https://wiki.squid-cache.org/SquidFaq/BinaryPackages
- OSX: Install SquidMan: https://squidman.net/squidman/
TODO
Modify your hosts file in order to include the following:
127.0.0.1 adclick.g.doublecklick.net
127.0.0.1 adeventtracker.spotify.com
127.0.0.1 ads-fa.spotify.com
127.0.0.1 analytics.spotify.com
127.0.0.1 audio2.spotify.com
127.0.0.1 b.scorecardresearch.com
127.0.0.1 bounceexchange.com
127.0.0.1 bs.serving-sys.com
127.0.0.1 content.bitsontherun.com
127.0.0.1 core.insightexpressai.com
127.0.0.1 crashdump.spotify.com
127.0.0.1 d2gi7ultltnc2u.cloudfront.net
127.0.0.1 d3rt1990lpmkn.cloudfront.net
127.0.0.1 desktop.spotify.com
127.0.0.1 doubleclick.net
127.0.0.1 ds.serving-sys.com
127.0.0.1 googleadservices.com
127.0.0.1 googleads.g.doubleclick.net
127.0.0.1 gtssl2-ocsp.geotrust.com
127.0.0.1 js.moatads.com
127.0.0.1 log.spotify.com
127.0.0.1 media-match.com
127.0.0.1 omaze.com
127.0.0.1 open.spotify.com
127.0.0.1 pagead46.l.doubleclick.net
127.0.0.1 pagead2.googlesyndication.com
127.0.0.1 partner.googleadservices.com
127.0.0.1 pubads.g.doubleclick.net
127.0.0.1 redirector.gvt1.com
127.0.0.1 s0.2mdn.net
127.0.0.1 securepubads.g.doubleclick.net
127.0.0.1 spclient.wg.spotify.com
127.0.0.1 tpc.googlesyndication.com
127.0.0.1 v.jwpcdn.com
127.0.0.1 video-ad-stats.googlesyndication.com
127.0.0.1 weblb-wg.gslb.spotify.com
127.0.0.1 www.googleadservices.com
127.0.0.1 www.googletagservices.com
...
Is this still valid on iOS 17, Spotify 2023 ?