How to build a headless Spotify Streaming box

Let's make a Spotify streaming box! Here are some of the things we need for this:

  • A headless Linux machine
  • Speakers
  • Spotify


Spotify has a feature called Spotify Connect that lets you use Spotify on one device as a remote for Spotify on another device. This lets you control music on your computer from you phone, for example.

Helpfully, they recently added support for Connect to their official (but unsupported) client for Linux.

Basic Instructions

  1. SSH into your machine and install Spotify for Linux.
  2. Install xvfb: sudo apt-get install xvfb. This is used as a dummy display for the Spotify application.
  3. Using X11 forwarding, login to Spotify (ssh with the -X or -Y flag and run the spotify command)
  4. Kill the spotify process and restart it using xvfb-run spotify. You may want to run this command on boot.
  5. Spotify Connect should work!

If you want more detail, continue reading. Otherwise, that's it!

Detailed instructions

First, let's follow Spotify's instructions for installing their Linux client.

If we try running spotify, we run into an issue almost immediately: the Spotify for Linux client doesn't work without a display. We can solve this problem by using xvfb to run it on a dummy display.

Great! However, we still need to login to Spotify before we can do anything useful. How do we do this without a display? The spotify command doesn't take any username or password arguments. Instead of using the dummy display, let's use X11 forwarding (ssh -X or ssh -Y) for now. This lets us "forward" the login window to a machine with a display. Once we login, we can go back to running spotify using xvfb. At this point, Spotify Connect should work and you should be able to control music on the headless box from other Spotify clients.