Today I will show you how to easily block the servers hosting Spotify ads on your Linux/Mac or Windows machine. This will allow you to listen all day long on a free account without hearing a single ad. This trick is very simple, legal and works great. Spotify may catch on and find some way to stop this from working but, as of today (5-November-2018) it works swimmingly.
Blocking Ad Server
In order to remove those pesky ads, all we need to do is setup out hosts file to override the DNS for Spotify’s ad servers and redirect that traffic to our local machine. When the traffic hits out local machine the call will fail and the ad will be skipped. Follow the steps below to add the entries needed.
Open your hosts file using your favorite text editor. I mostly use terminal in Linux. Add the following lines to the bottom of your hosts file and save your hosts file (Look below How To in your favour OS):
RAW File: https://pastebin.com/raw/9M5ALu8n
# Block Spotify Ads127.0.0.1 media-match.com127.0.0.1 adclick.g.doublecklick.net127.0.0.1 http://www.googleadservices.com127.0.0.1 open.spotify.com127.0.0.1 pagead2.googlesyndication.com127.0.0.1 desktop.spotify.com127.0.0.1 googleads.g.doubleclick.net127.0.0.1 pubads.g.doubleclick.net127.0.0.1 securepubads.g.doubleclick.net127.0.0.1 audio2.spotify.com127.0.0.1 http://audio2.spotify.com127.0.0.1 http://www.audio2.spotify.com127.0.0.1 http://www.omaze.com127.0.0.1 omaze.com127.0.0.1 bounceexchange.com127.0.0.1 core.insightexpressai.com127.0.0.1 content.bitsontherun.com127.0.0.1 s0.2mdn.net127.0.0.1 v.jwpcdn.com127.0.0.1 d2gi7ultltnc2u.cloudfront.net127.0.0.1 crashdump.spotify.com127.0.0.1 adeventtracker.spotify.com127.0.0.1 log.spotify.com127.0.0.1 analytics.spotify.com127.0.0.1 ads-fa.spotify.com127.0.0.1 cs283.wpc.teliasoneracdn.net127.0.0.1 audio-ec.spotify.com127.0.0.1 cs126.wpc.teliasoneracdn.net127.0.0.1 heads-ec.spotify.com127.0.0.1 u.scdn.co127.0.0.1 cs126.wpc.edgecastcdn.net127.0.0.1 pagead46.l.doubleclick.net127.0.0.1 pagead.l.doubleclick.net127.0.0.1 video-ad-stats.googlesyndication.com127.0.0.1 pagead-googlehosted.l.google.com127.0.0.1 partnerad.l.doubleclick.net127.0.0.1 prod.spotify.map.fastlylb.net127.0.0.1 adserver.adtechus.com127.0.0.1 na.gmtdmp.com127.0.0.1 anycast.pixel.adsafeprotected.com127.0.0.1 ads.pubmatic.com127.0.0.1 idsync-ext.rlcdn.com127.0.0.1 http://www.googletagservices.com127.0.0.1 sto3.spotify.com127.0.0.1 spclient.wg.spotify.com127.0.0.1 d361oi6ppvq2ym.cloudfront.net127.0.0.1 gads.pubmatic.com127.0.0.1 ads-west-colo.adsymptotic.com127.0.0.1 geo3.ggpht.com127.0.0.1 showads33000.pubmatic.com127.0.0.1 spclient.wg.spotify.com
For Windows 10 & 8
- Press the Windows key.
- Type Notepad in the search field.
- In the search results, right-click Notepad and select Run as administrator.
- From Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts
- Make the necessary changes to the file.
- Click File > Save to save your changes.
- Open a terminal window.
- Open the hosts file in a text editor (you can use any text editor) by typing the following line:
sudo nano /etc/hosts
For Mac OS X 10.6 through 10.12
- Open Applications > Utilities > Terminal.
- Open the hosts file by typing the following line in the terminal window:
sudo nano /private/etc/hosts
- Type your domain user password when prompted.
- Edit the hosts file.The file contains some comments (lines starting with the # symbol), and some default hostname mappings (for example, 127.0.0.1 – local host). Add your new mappings after the default mappings.
- Save the hosts file by pressing Control+x and answering y.
- Make your changes take effect by flushing the DNS cache with the following command:
There you go, editing hosts file has taken effect.
Why This Works?
To understand how this works we first need to understand the role DNS plays in our operating system. When we are communicating with other services on the web everything is referenced by IP address. For instance, when I tell my browser to go to google.com, it has to know where to find google.com. This is where DNS comes into play. DNS short for Domain Name Servers is a service that translates human readable, easy to remember domain names into IP addresses that other machines can communicate with. Whenever you add an entry to your local hosts file you are overriding the DNS entry locally for whatever domain you enter. For instance, if I add the line “127.0.0.1 test.local” to my hosts file, whenever i type “test.local/” into my browser, it will see the entry in my hosts file and use the IP 127.0.0.1(locahost) rather than reaching out to a DNS server to try and resolve that address. Where this comes into play for us is overriding Spotify ad servers. When we add an entry for each server that hosts ads for Spotify and points them to our local machine, we are ensuring that whenever Spotify reaches out for an add it hits our local machine instead of the real ad server and gets an error. When Spotify detects this error it stops trying to attempt to run the ad and the ad is skipped.