A Raspberry Pi makes a great multi-protocol audio receiver – pair it with a set of speakers and you can stream to it via AirPlay from any Apple device, or via Spotify Connect directly from the Spotify app. This Raspberry Pi AirPlay Spotify Connect guide covers setting up both shairport-sync for AirPlay and Raspotify for Spotify Connect on a headless Pi.
Updated October 2026: added a quick overview, an AirPlay 2 timing note and extra troubleshooting.
The short version: on a Pi running Raspberry Pi OS Lite, you need two separate services. shairport-sync makes the Pi an AirPlay receiver, and Raspotify (built on librespot) makes it a Spotify Connect device. Both run at once and share the same speakers.
- Flash Raspberry Pi OS Lite (64-bit) with SSH and Wi-Fi configured in Raspberry Pi Imager.
- Build and install shairport-sync, then enable the
shairport-syncservice. - Install Raspotify with its install script and set the device name in
/etc/raspotify/conf. - Check both services show
active (running), then pick the Pi as an output from your iPhone, Mac or the Spotify app.
What you’ll need
- A Raspberry Pi (Pi 3, 4, or 5 recommended – Pi Zero 2 W works well for a compact build)
- A micro SD card with Raspberry Pi OS Lite installed
- Speakers connected via 3.5mm jack or a USB audio adapter
- An active Spotify Premium account (required for Spotify Connect)
- SSH access to your Pi
1. Flash and set up
Use Raspberry Pi Imager to flash Raspberry Pi OS Lite (64-bit). In the imager’s advanced settings, set your hostname, enable SSH, and configure your Wi-Fi before writing. This means you can boot headless and SSH straight in – no monitor needed.
ssh pi@raspberrypi.local
sudo apt update && sudo apt upgrade -y
2. Install shairport-sync for AirPlay
shairport-sync is the gold standard open source AirPlay receiver. It supports AirPlay 1 (all Apple devices) and AirPlay 2 in recent builds.
Install the dependencies:
sudo apt install -y build-essential git autoconf libtool libdaemon-dev libasound2-dev libpopt-dev libconfig-dev avahi-daemon libavahi-client-dev libssl-dev libsoxr-dev libplist-dev libsodium-dev libavutil-dev libavcodec-dev libavformat-dev uuid-dev xxd libglib2.0-dev
Clone and build shairport-sync:
git clone https://github.com/mikebrady/shairport-sync.git
cd shairport-sync
autoreconf -fi
./configure --sysconfdir=/etc --with-alsa --with-soxr --with-avahi --with-ssl=openssl --with-systemd --with-airplay-2
make
sudo make install
AirPlay 2 note: the --with-airplay-2 build option relies on a separate timing service called NQPTP, which the shairport-sync project provides, and it needs exclusive access to network ports 319 and 320 (so make sure a firewall is not blocking them). It also needs an FFmpeg build with a suitable AAC decoder. The shairport-sync BUILD.md covers the exact AirPlay 2 build steps. If you only need classic AirPlay (AirPlay 1), shairport-sync can be built without AirPlay 2 support.
Enable and start the service:
sudo systemctl enable shairport-sync
sudo systemctl start shairport-sync
Your Pi will now appear as an AirPlay speaker in Control Centre on iPhone, iPad, and Mac. The default name is the Pi’s hostname – you can change it in /etc/shairport-sync.conf under the general section:
general = {
name = "Living Room Pi";
};
3. Install Raspotify for Spotify Connect
Raspotify wraps librespot into a convenient Debian package. It makes the Pi appear as a Spotify Connect device, so you can cast to it from the Spotify app on any device on your network.
Install it with the official script:
curl -sL https://dtcooper.github.io/raspotify/install.sh | sh
Configure it in /etc/raspotify/conf. The key options:
LIBRESPOT_NAME="Living Room Pi"
LIBRESPOT_BITRATE="320"
LIBRESPOT_DEVICE_TYPE="speaker"
Restart the service after any config changes:
sudo systemctl restart raspotify
Open Spotify on your phone or laptop, tap the speaker icon, and you should see your Pi listed as an available device.
4. Running both at once
shairport-sync and Raspotify can run simultaneously without conflict – they each grab the audio output independently, and only one will be active at a time. There’s no configuration needed to make them co-exist; just ensure both services are enabled and running:
sudo systemctl status shairport-sync
sudo systemctl status raspotify
Both should show active (running).
Troubleshooting
Pi not showing up as AirPlay device: Check Avahi is running with sudo systemctl status avahi-daemon. AirPlay discovery uses mDNS, so Avahi needs to be active for the Pi to advertise itself on the network.
No audio output: Run aplay -l to list audio devices and confirm your output is detected. If you’re using a USB audio adapter, it may not be set as the default ALSA device. Check /etc/asound.conf or set LIBRESPOT_DEVICE in the Raspotify config to target your USB adapter explicitly.
Audio quality is poor: The Pi’s built-in audio is adequate but not hifi. A HiFiBerry HAT or a decent USB DAC like the AudioQuest DragonFly makes a significant difference, especially for AirPlay which can stream lossless audio from Apple Music.
Spotify Connect not appearing: Raspotify requires a Spotify Premium account. Free accounts don’t support Connect. Also ensure your phone and Pi are on the same network – Connect doesn’t work across VLANs without mDNS forwarding.
AirPlay 2 will not connect or drops out: check that NQPTP is running and that nothing else is using ports 319 and 320 or blocking them on your network. If you only need classic AirPlay, a build without AirPlay 2 avoids this dependency altogether.
Raspotify will not install: the Raspotify project targets Debian-based systems and is not supported on ARMv6 Pis (the original Pi and Pi Zero v1.x). The Pi Zero 2 W and newer models are not affected.
Going further
With AirPlay and Spotify Connect both running, you’ve got a capable wireless audio receiver that works natively with Apple devices and Spotify without any special apps on the sending device. A few things worth adding:
- Add Bluetooth A2DP support alongside AirPlay and Spotify Connect – see our Raspberry Pi Bluetooth A2DP guide
- Use a Pi Zero 2 W for a tiny, low-power build that runs all three protocols
- Put the Pi in a project enclosure with a small amplifier board for a fully self-contained wireless speaker
