The message is one of the few consumer errors that mentions proxies by name: "A firewall may be blocking Spotify. Please update your firewall to allow Spotify. Additionally you could try to change the currently used proxy settings. (Error code: 4)". It appears at sign-in or when the desktop app opens, on a computer whose internet is otherwise working, and it sends people into two settings screens at once, the firewall's and the proxy's. Both are the right places to look, and the order matters less than knowing what each one does.
Spotify's desktop app makes its own connections to Spotify's servers, and it has its own proxy setting, separate from the browser's and from the operating system's. By default that setting is Auto-detect, which tells the app to follow whatever proxy the computer is configured with. That default is why a proxy the user never knowingly set up, a leftover from a VPN or a security suite, or the proxy of an office network, breaks Spotify while everything in the browser still loads: the browser may be handling it differently, and Spotify simply fails. Code 4 is the app reporting that it could not get through, with two guesses attached.
Fix 1: set Spotify to No proxy
Open the desktop app, click your name or the menu, choose Settings, and scroll to Proxy settings. The Proxy type dropdown offers Auto-detect settings, No proxy, HTTP, SOCKS4, and SOCKS5, with fields for host, port, username, and password. Set it to No proxy and restart the app.
For most people this is the whole fix, because it stops Spotify from following a system proxy that does not work. If the app opens after the restart, a proxy configured on the computer was the cause, and it is worth finding: open Settings, Network & internet, Proxy on Windows (or System Settings, Network, your connection, Details, Proxies on a Mac), read the address, and switch it off if it is not one you or your organisation put there. How to turn off a proxy explains what a 127.0.0.1 address means versus an unfamiliar public one, and when a leftover is worth a scan.
If Spotify's proxy type was already set to HTTP or SOCKS with an address you do not recognise, the same applies: a program set it, and clearing it is the fix.
Fix 2: allow Spotify through the firewall
The first half of the message. Windows Defender Firewall normally allows Spotify when it is installed, but a third-party firewall or an antivirus suite with a "web shield" or "application control" feature frequently does not, especially after a Spotify update changes the executable.
On Windows, open Windows Security, Firewall & network protection, Allow an app through firewall, click Change settings, and confirm Spotify is listed and ticked for private and public networks; if it is missing, Allow another app and browse to it. Then open the third-party product's application or firewall list and allow Spotify there too. The fastest diagnostic is to disable the third-party product for a minute and open Spotify: if it signs in, add the exception and turn the product back on. On a Mac, System Settings, Network, Firewall, Options lists blocked apps.
Fix 3: turn off the VPN
A VPN reroutes everything, and some VPN exits are blocked by Spotify's servers, or the VPN's own configuration interferes with the app's connections. Disconnect the VPN and open Spotify. If it works, the VPN is the cause; reconnect to a different server, or leave Spotify outside the VPN using the VPN's split-tunnelling feature where it has one. A VPN that is half-connected or that has crashed also produces code 4, and reconnecting or restarting the client fixes that.
Fix 4: check DNS
If Spotify cannot resolve its server names, it cannot connect, and the error looks identical. Set the connection's DNS to a public resolver such as 1.1.1.1 or 8.8.8.8 and restart the app. On Windows, ipconfig /flushdns in a terminal clears a stale cache first.
Fix 5: the network itself
Offices, schools, dormitories, and some hotels either require a proxy that Spotify's Auto-detect follows and cannot log in to, or block streaming outright. Setting No proxy handles the first. For the second, the same computer will work at home and on mobile data, which is the test, and only the network's administrator can change it.
Fix 6: the app's own state
Rarely, the app's cached data is corrupt. Sign out, quit fully (including from the system tray), and sign in again. If that fails, uninstall, delete the leftover Spotify folder in the application data directory, and reinstall. Reinstalling does nothing for the firewall, the proxy, the VPN, or DNS, which is why it belongs at the end of the list rather than the start.
Using a proxy with Spotify on purpose
Spotify's proxy settings exist for a reason, and some readers arrive here because a proxy they configured deliberately has stopped working. The app accepts HTTP, SOCKS4, and SOCKS5 proxies with a username and password, and it needs a restart after any change. Code 4 with a deliberate proxy means the proxy is dead, slow, refusing the app's connections, or asking for credentials it is not receiving. Test the address in our proxy checker first: a dead or slow result explains everything, and public proxies produce that result constantly, which our post on free proxies for Spotify covers in detail. A proxy that has to carry a streaming session needs to stay up and keep one address for hours; a fixed ISP proxy or a residential line with a sticky session is the kind that does, and the Spotify proxy guide covers the setup. Spotify's terms and its regional rules apply to the account regardless of the address it connects from.
The order that works
Set Spotify's proxy type to No proxy and restart. Allow the app through Windows Firewall and any third-party security product. Turn the VPN off. Switch DNS to a public resolver. If it works everywhere except one network, that network is blocking it. And if the proxy was deliberate, test it before you blame the app.