Getting raspotify to work with UFW

Getting raspotify to work with UFW






Raspberry Pi 4

Operating System

Rasbian Buster


My Question or Issue

Hey guys, I'm trying to get Spotify to detect my raspberry pi which is using raspotify ( 
If I were to disable UFW, I'm able to connect to my raspberry pi with no issues.

However, whenever UFW is enabled Spotify can't detect the pi.

Any ideas what UFW rule should I add to make it work? 



2 Replies


Check your logs to see what ufw is blocking, and adjust your rules accordingly. I'd recommend creating a ufw app profile. That way if it the port you are opening up keeps changing you just need to edit the app profile and reload it against your active rules.


If the port is changing, you will need to either find a way to capture the port and add it to your rules, or set the port via startup options in the app itself.  There is a rough outline to one way of approaching the former in the comments on issue #126 of raspotify. The options page of the librespot wiki lists an setting called 'zeroconf-port' that might solve the problem using the latter method, but you'll need to figure out how to pass that option from rapsotify to librespot.


It might be worth popping into the chat room listed on the main page of the librespot Github repo to see if anyone in there has worked through this already, as the topic has come up in the issues pages of both projects on several occasions.


You can allow all outgoing connections with


sudo ufw default allow outgoing

sudo ufw reload


Then it should work. Otherwise you'd need to find the exact ports the client is using. See also:

Suggested posts