How To

How to automatically start Airplay on your Raspberry Pi with Shairport Sync

Assuming you are using a Raspberry Pi board as part of your home network streaming solution, and assuming you have already taken the time to install and configure Shairport Sync to enable Airplay for your Raspberry Pi as part of that solution, you might have run into the issue of losing your Airplay connection each time you restart your Raspberry Pi.

One solution is to simply open up terminal (or another command-line interface), ssh in your Raspberry Pi and re-run the command to start Shairport Sync manually.

I think that’s a bit of a hassle for me because I’m frequently moving my Raspberry Pi streamer to different parts of the house and I don’t particularly enjoy firing up terminal to re-run a bunch of commands each time I re-arrange things.

Luckily, you can enable Shairport Sync start automatically each time your Raspberry Pi powers on. This won’t automatically connect your Airplay enabled device (like your iPhone or tablet, for example) to the Raspberry Pi. This will simply make the Raspberry Pi available as an optional Airplay endpoint.

How to automatically start Airplay on your Raspberry Pi with Shairport Sync

How to automatically start Airplay on your Raspberry Pi with Shairport Sync
How to automatically start Airplay on your Raspberry Pi with Shairport Sync

This guide will show you how to automatically start Airplay on your Raspberry Pi using Shairport Sync.

Project Cost: $0 – $0

Total Time: 5 Min.

Tools and Supplies

Here is a list of tools and equipment that you should have on hand before you begin this project:

Tools

  • Terminal or another Command Line Interface tool

    You’ll need to use Terminal or a similar Command Line Interface (CLI). It will be helpful if you already have some experience with CLIs, but these steps should still be simple enough for someone without command line experience to follow.

Supplies

  • A Raspberry Pi

    If you don’t have a Raspberry Pi handy, I would recommend buying a Raspberry Pi 4 or 5 Starter Kit from CanaKit.

    Canakit offers a variety of kits, but each configuration will include everything you’ll need to get started. In writing this tutorial I’m using a Raspberry Pi 4 with 4GB of RAM.

  1. SSH into your Raspberry Pi

    With Raspberry Pi OS installed on your Micro-SD card and your Raspberry Pi powered on you’ll want to make sure you can SSH into the Pi.

    If you need a refresh on how to SSH into your Raspberry Pi you can visit the guide How To SSH or Secure Shell into your Raspberry Pi

    On your computer launch your command-line interface app (Terminal, in my case) and enter the following command, where username is the SSH username and hostname is the hostname you created in Raspberry Pi Imager:

    ssh username@hostname.local

    Hit ENTER

  2. Enable Shairport Sync at start up

    Now, run this command in terminal to enable Shairport Sync to run at start up:

    sudo systemctl enable shairport-sync

    Hit ENTER

    You see a message returned that looks something like Created symlink /etc/systemd/system/multi-user.target.wants/shairport-sync.service → /lib/systemd/system/shairport-sync.service

  3. Reboot the Raspberry Pi

    Now you’ll need to restart your Raspberry Pi to ensure the changes take effect and your Airplay endpoint is available.

    Enter this command in terminal:

    sudo reboot

    Hit ENTER

    Wait a few moments for the Raspberry Pi to reboot.

  4. Start Streaming

    And that shoule be it! Now use an Airplay enabled device to target you Raspberry Pi and start streaming.

    Your default audio output (headphones, HDMI, DAC Hat, etc.) should be working as it usually does while using Airplay, but if you run into any issues with that please leave a comment below.