Turning a Raspberry Pi into an AirPlay and Spotify Connect Receiver with Shairport-Sync and Raspotify
This site already covers building a Raspberry Pi into a full whole-home audio streaming server with Volumio and multi-room sync, which is the right project if you're building a serious music server from scratch. But a lot of the time what you actually want is much simpler: turn an old pair of powered speakers or a stereo receiver into an AirPlay or Spotify Connect target, so your phone can just throw audio at it the way it would to a HomePod or a smart speaker, without running a full media server. That's a smaller, cheaper project, and it's what Shairport-Sync and Raspotify are built for. This guide covers setting up both on a single Pi so it answers to AirPlay from iOS/macOS and Spotify Connect from any Spotify client, sharing one audio output.
What Each Piece Does
- Shairport-Sync emulates an AirPlay (and AirPlay 2, with the right build options) receiver. It announces itself over Bonjour/mDNS so it shows up automatically in the AirPlay picker on any iPhone, iPad, or Mac on the same network, and streams whatever audio is sent to it out through the Pi's audio output.
- Raspotify is a packaged build of librespot, an open-source Spotify Connect client, set up to run as a systemd service. It makes the Pi show up as a Spotify Connect device in the Spotify app's device picker, the same way a Sonos or a smart TV would.
Running both at once is a common and well-supported combination — they don't conflict, since each only activates when its respective protocol actually starts streaming, and normal use means only one is active at a time anyway.
Hardware Considerations
Audio output quality depends entirely on how you get sound out of the Pi, and this is worth deciding before you start:
Output MethodQualityNotes Pi's built-in 3.5mm jackMediocre — audible noise floorFine for casual/background listening, not for a serious speaker setup USB DAC (even a cheap one)GoodEasiest upgrade path, works with any Pi model, no GPIO needed I2S DAC HAT (PCM5102A, HiFiBerry, IQaudio)Very goodBypasses the Pi's onboard audio entirely, best option for a dedicated build HDMI (into an AV receiver)GoodSimplest if the destination is already an HDMI-input receiverA Pi Zero 2 W is plenty of compute for this — both Shairport-Sync and Raspotify are lightweight, so there's no reason to dedicate a Pi 4 or 5 to what's fundamentally a network audio bridge.
Installing Shairport-Sync
On recent Raspberry Pi OS, Shairport-Sync is available directly from the package repos, which is the easiest path:
sudo apt update sudo apt install shairport-syncThe default config at /etc/shairport-sync.conf is usable out of the box, but two settings are worth checking:
- general.name — set this to whatever you want the device to show up as in the AirPlay picker (e.g. "Living Room").
- alsa.output_device — if you're using a USB DAC or I2S HAT rather than the built-in jack, point this at the correct ALSA device name (find it with aplay -l).
If you need full AirPlay 2 support (multi-room grouping with real Apple devices, not just basic single-target streaming), you'll need to build Shairport-Sync from source with the AirPlay 2 feature flags enabled rather than using the packaged version, which typically only supports "classic" AirPlay 1. For a single-speaker bridge, classic AirPlay is sufficient and much less setup.
Installing Raspotify
Raspotify ships its own install script that sets up the systemd service and package repo for you:
curl -sL https://dtcooper.github.io/raspotify/install.sh | shConfiguration lives in /etc/raspotify/conf. The settings worth changing immediately:
- LIBRESPOT_NAME — the name shown in the Spotify Connect device list.
- LIBRESPOT_BITRATE — set to 320 if you have a Spotify Premium account and want the highest quality stream (Raspotify only works with Premium accounts, since Spotify's free tier doesn't support Connect).
- LIBRESPOT_DEVICE — same idea as Shairport-Sync's ALSA output setting, point it at your USB DAC or I2S HAT if you're not using the built-in jack.
Restart the service after any config change with sudo systemctl restart raspotify.
Running Both Together
Both services bind to the same ALSA output device but don't need exclusive access simultaneously in normal use, since only one plays audio at a time. If you do run into audio device contention (one service holding the device open and blocking the other), routing both through dmix in ALSA, or through PulseAudio/PipeWire as a shared audio server, resolves it — but for a simple single-speaker bridge most people never hit this in practice, since AirPlay and Spotify streaming sessions are inherently exclusive from the source side.
Troubleshooting
SymptomLikely Fix Device doesn't show up in AirPlay pickerCheck that mDNS/Bonjour traffic isn't blocked — a VLAN or guest network without multicast forwarding will hide it; confirm with avahi-browse -a on the Pi Device doesn't show up in Spotify ConnectConfirm the raspotify service is actually running (systemctl status raspotify) and that you're logged into a Premium account in the Spotify app Audio stutters or dropsUsually WiFi signal to the Pi — move it closer to the AP or switch to Ethernet, especially for a Pi Zero 2 W's single-band WiFi No sound at all despite a connected sessionWrong ALSA output device set in one or both configs — re-check with aplay -l and match the card/device numbers exactlyThis is a genuinely small project as far as Pi builds go — an afternoon, at most, once you've got the DAC hardware sorted — but it's one of the more satisfying ones because the payoff is immediate and used daily. It's worth thinking of as the lightweight alternative to the full Volumio/multi-room setup already covered on this site: reach for Shairport-Sync and Raspotify when you just want to turn a pair of speakers into an AirPlay/Spotify target, and reach for the full Volumio build when you actually want a music server with its own library and multi-room sync.
Related Guides
- ESP32 I2S Audio: Playing and Recording Sound with a MAX98357A DAC and INMP441 Microphone
- Build a Raspberry Pi Whole-Home Audio Streamer: Volumio, DAC HAT, and Multi-Room Sync
- How to Install Klipper on Any 3D Printer: Complete Setup Guide
- How to Set Up OpenCV Machine Vision on a Raspberry Pi
- Raspberry Pi: Complete Headless Setup Guide (No Monitor Needed)
- Raspberry Pi: Headless OS Setup
- How to Set Up a Raspberry Pi Headless with SSH and WiFi
- How to Install and Configure Pi-hole on Raspberry Pi