Spotify is a media-services provider especially known for its audio streaming services. Based in Sweden, Spotify was founded in 2006. The company has slowly gained notoriety and is offering its services in more and more countries. Along with the website, Spotify also has a Windows application that you can download and install on your system. However, in some cases, logging in can become a hurdle and you will be shown an error message every time you try to log in. The error code 2 comes during the same phenomena. The cause of the error is usually having something wrong with your network connection.
Since Spotify is one of the most-used apps for listening to music so this error is quite common and there are a lot of solutions for it that you can try to get rid of the error which has helped many other people as well.
What causes the Spotify Error Code 2?
Now, as the error message appears while trying to log in, there can be a variety of causes of this error and the cause would vary from one user to another. Some of the most common causes of this error include:
- Behind Proxy/Firewall: If you are using the Spotify app on your computer and you are behind a proxy or a strict firewall then it is possible that the rules set up on your network’s proxy or firewall do not allow you to use Spotify since it’s blocking Spotify connections. Sometimes, network administrators set up such limitations on their network so that the users can’t use certain apps like Spotify because they block the ports used by these apps or the domains/IP addresses used by these apps to connect and authenticate with their servers. Thus, being behind a strict firewall or a proxy can be a cause of this error.
- DNS cache not flushed for some time: If you are using a Windows machine and you have not flushed your DNS cache for a while (many people actually don’t), then the error may be caused because there is much junk in your DNS cache which is not allowing the Spotify app to connect to its servers. This happens because the app is not able to resolve the IP address of the domains/URLs used by it to connect to its servers if your DNS cache has not been flushed.
- Having Spotify nameservers/domains blocked in your hosts file: Another possibility is that something might have tweaked your hosts file and added the Spotify nameservers/domains/IP addresses to the blacklist due to which your machine is not able to access or connect to the Spotify servers.
- Corrupt Spotify app: In some occasions, if your Spotify app has been corrupted by a malware or virus or the files of the application has been corrupted then you could get this error. The remedy here is to reinstall Spotify.
There are some solutions listed below that you can try to get rid of this error. Since the validity of the solution depends upon the cause of the problem so every solution might not work for you. Be sure to try them all.
Solution 1: Clean reinstall of Spotify
The first solution that you can try is to perform a clean installation of Spotify on your computer. To do that, you need to completely uninstall Spotify from your system first and then proceed to install Spotify again. Here’s how to do that:
- First of all, uninstall Spotify first from Control Panel in Windows.
- Then, open run dialog box by pressing Windows Key + R and type %AppData%.
- From there, delete any Spotify folders you see inside the Local and Roaming
- After that, reboot your computer and download the latest Spotify for your Windows and install it.
If the error was caused due to your Spotify being corrupted or something like that, then by performing a clean reinstall would hopefully fix the problem for you.
Solution 2: Flush DNS in Windows
Sometimes, if there is quite a junk in your DNS cache then it’s possible that Spotify nameservers are not properly resolved to their IP addresses. The workaround here is to Flush the DNS cache in Windows. Doing that is pretty easy, here’s how:
- Open Start Menu and type cmd.
- Right-click on the first selection and click Run as Administrator.
- After the command prompt is opened, type this command and press Enter.
Solution 3: Remove any Spotify nameservers from hosts File
If you have any Spotify nameservers blacklisted in your Windows hosts file then you will not be able to use Spotify at all or connect to Spotify servers. The workaround here is to see if you have any such entries in your hosts file.
- To do that, open Start Menu and search for Notepad.
- Open Notepad with Administrator rights by right-clicking on its icon and clicking on Run as Administrator.
- Now click on the File option in the menu bar and select Open.
- Browse to C:\Windows\System32\drivers\etc directory and open the file named as hosts.
- Now the hosts file will open in your Notepad.
- Check if any entries containing Spotify or fastly are present inside the file. An example of such entries is given below:
- See if there is any entry with Spotify and remove it from the hosts file. Then close the hosts file and see if you can log in to your Spotify account afterward.
Solution 4: Turn off Antivirus/Firewall
It is indeed a possibility that if you are using any antivirus other than Windows Defender or a strict firewall policy on your computer then they might be blocking Spotify’s access to its servers. Turn off any other antivirus that you might have installed on your computer other than Windows Defender and turn off the Windows Firewall as well. After doing that, check again and see if you can use Spotify and login to your account then.
Solution 5: Restart your Router
A user on the Spotify forums reported that his/her issue was solved after rebooting the router. Sometimes, routers are not able to properly resolve the nameservers of domains to IP addresses and they would need a restart to get them fixed. So, you can try rebooting the main router of your network and see if your problem goes away afterward.