To disconnect Raspotify or Librespot from Spotify Connect on a Raspberry Pi 3, you must disable the service so it stops advertising itself as a playback device. This prevents your phone or other devices from controlling the speakers connected to the Pi. The process involves stopping the active daemon and disabling its startup configuration through the system's init management tools.
Understanding the Service Architecture
Raspotify is essentially a wrapper around
librespot, an open-source Spotify Connect client written in Rust. When installed on your Raspberry Pi 3, it runs as a background service that listens for connection requests on port 4070 by default. This allows any device on the same local network with the Spotify app to discover and stream audio to your Pi. While this feature is convenient for smart home setups, there are valid reasons to remove this capability entirely, such as preventing unauthorized access, reducing CPU load when not in use, or isolating the Pi for other tasks like media serving via SMB or NFS.
Disabling the service does not uninstall the software. Your existing configuration files remain intact, meaning you can re-enable Spotify Connect functionality at any time if your needs change. However, once disabled, the device will no longer appear in the list of available outputs within the Spotify application on your mobile phones, tablets, or computers.
Stopping the Active Session
Before permanently disabling the service, it is important to ensure that the current session is terminated immediately. If the service is currently running, your connected speakers may continue to receive audio commands until the process is killed. You can manage this using the
systemctl command, which is the standard interface for managing systemd services on modern Linux distributions including Raspbian (now Raspberry Pi OS).
First, stop the running instance of the service by executing the following command in your terminal:
sudo systemctl stop raspotify
This command sends a signal to the operating system to halt the
raspotify process. You can verify that the service has stopped by checking its status. Run the following command to see the current state:
systemctl status raspotify
Look for the line that says "Active: inactive (dead)" or "stopped". If the service shows as active, wait a few seconds and check again. In some rare cases where the service hangs, you may need to forcefully kill the process using
pkill -f librespot, but typically the
systemctl stop command handles this cleanly. Once the service is stopped, your Raspberry Pi will cease responding to Spotify Connect discovery packets.
Preventing Automatic Restart
Stopping the service temporarily is not enough because systemd is designed to restart failed or stopped services depending on its configuration. To ensure that Raspotify does not start automatically upon reboot or after a manual restart attempt, you must disable the unit file. This changes the service's state from "enabled" to "disabled", effectively removing it from the boot sequence.
Execute the disable command as follows:
sudo systemctl disable raspotify
This command creates a symbolic link removal in the
/etc/systemd/system/multi-user.target.wants/ directory, ensuring that the service is not launched during the multi-user target phase of the boot process. After running this command, you should verify the change by running
systemctl is-enabled raspotify. The output should clearly state "disabled".
It is worth noting that disabling the service does not remove the binary or the configuration files located in
/etc/default/raspotify. If you ever wish to re-enable Spotify Connect, you can simply run
sudo systemctl enable raspotify followed by
sudo systemctl start raspotify. Your previous settings, such as volume limits and bitrate preferences, will be preserved.
Alternative Disconnection Methods
If you prefer not to use the command line or want a more temporary solution, you can also block the service via firewall rules. By denying traffic on port 4070, you prevent external devices from discovering the Pi even if the service remains enabled. However, this method is less clean than disabling the service because the resource usage continues in the background. For most users, the
systemctl disable approach is the most efficient way to reclaim system resources and ensure privacy.
For those experiencing broader connectivity issues related to Spotify Connect, such as devices failing to appear due to network segmentation, refer to our guide on
Librespot Troubleshooting. Network isolation can sometimes mimic the behavior of a disabled service, so verifying your network configuration is a good diagnostic step before modifying system services.
Frequently Asked Questions
Does disabling Raspotify delete my account data?
No, disabling the service only stops the background process from running. It does not affect your Spotify account credentials stored in the configuration files. Your login details remain saved in
/etc/default/raspotify and can be reused if you re-enable the service later.
How do I completely remove Raspotify from my Raspberry Pi?
If you want to uninstall the software entirely rather than just disable it, use the package manager command
sudo apt purge raspotify. This removes the binaries, configuration files, and dependencies associated with the package, freeing up disk space completely.
Can I control the Pi via Spotify if I disable the service?
No, once the service is disabled and stopped, the Raspberry Pi will no longer advertise itself on the local network. Devices running the Spotify app will not see the Pi as an available output option, and you will lose the ability to cast audio to it until the service is re-enabled.
Will disabling Raspotify affect other audio outputs like ALSA?
No, disabling Raspotify only affects the Spotify Connect listener. Other applications that play audio directly through the Advanced Linux Sound Architecture (ALSA) or PulseAudio will continue to function normally. You can still play music files locally without interference from the disabled Spotify service.