evilfactorylabs

Cover image for Running a personal music streaming server using Navidrome
Rizaldy
Rizaldy

Posted on

Running a personal music streaming server using Navidrome

There are two kinds of people in the world: those who listen to music and those who don't. Despite the variety of people's views on music, music itself is pure and impartial.

Since the story tends to be more about flashbacks, here is mine: back in 2009 I was lucky enough to get an "mp3 player" from my uncle and one of the playlists I remember to this day was Kupu-Kupu Malam performed by Peterpan. Living in a rural area means limited access including to the original work of artists that produce the music. Copying music across media was as simple as Copy-Paste as far as I remember, no ripping required.

Some time around the 2010s the internet became a thing and I also moved to an urban area. Some people will recognize what "stafaband", "4shared" and maybe "idws" mean. On the other hand, in the city where I used to live, there was a market that sold mp3 files as a commodity. Something like 10rb IDR per 100 files for fucking real. Since the internet used to be an expensive good maybe losing 10rb to get ~300 MB worth of files was a good deal remembering how fast ADSLs were back then.

Today it's a different story. People tend to prefer streaming like accessing anything over the wire anytime. This is understandable remembering most people have more than one computer including something called phone.

And organizing files is such a chore.

But the idea is pretty simple: put files in one place with gigantic storage with lightning fast transfer speed and let the rest access it when needed, over the network.

You may be wondering with all of this information.

And here is the question: do you like music? Do you like collecting like a lot of good music you want to listen anytime anywhere? Do mainstream music streaming services not feel right for you?

If so, then this post is for you.

What is Navidrome?

According to its GitHub README:

Navidrome is an open source web-based music collection server and streamer. It gives you freedom to listen to your music collection from any browser or mobile device. It's like your personal Spotify!

The last part is the most important and easiest to understand for a wider people.

A server is basically just a computer, but is more likely to run 24/7 depending on your needs. It serves requests, like web requests. In short, you can treat every computer as a server.

While most servers runs Linux, Navidrome runs on nearly all major operating systems like Windows, macOS, FreeBSD and of course GNU/Linux. And unlike other modern programs that sometimes require more power to run, Navidrome is lightweight with very low resource usage. It runs well on simple Raspberry Pi Zero and old hardware setups according to its claim.

Because Navidrome is a Music Streaming Server, it means you need a music collection. You can buy online like from iTunes (my personal favorite) or you can always rip your CD collections. It's best if you already have one.

Now the hardest part: you probably have no idea how complex programs is because that's how software developers want it. This software industry even has two dedicated roles like UX and DX just to make sure people don't hate their programs, including the developers themselves.

My personal recommendation—even though I hated it—is to use Docker. Docker runs nearly anywhere. If you already know how to manage programs and their lifecycle, your best bet is to not use it if only for this particular need as Navidrome is a cross-platform program.

Installing Docker is pretty straightforward, just head to the Docker Desktop download page especially if you're on Windows and not using WSL that much. If you're on macOS, my personal recommendation is OrbStack. If you're on GNU/Linux, you already know what to do.

And now, the run part.

The Navidrome docker image (the "program") is hosted on Docker Hub which is accessible at deluan/navidrome. The program listens on port 4533, so make sure the port is available (most likely). For the directories/folders, Navidrome only uses two:

  • /data this is where it stores any metadata and stuff
  • /music this is your music collection

Assuming your music collection is in /Users/sigma/Music, you need to run this in your Terminal/Command Prompt:

docker run -d --restart=unless-stopped \
  -v navidrome-data:/data \
  -v /Users/sigma/Music:/music:ro \
  -p 4533:4533 deluan/navidrome
Enter fullscreen mode Exit fullscreen mode

Here is the breakdown:

  • -d means run in "detached mode" or in the "background".
  • --restart means its restart policy. Using unless-stopped means the program will auto-start even after a reboot unless it is manually stopped.
  • -v means to "mount" a volume. The first one (navidrome-data) uses Docker-managed volume while the last one mounts your existing volume.
  • -p means to map the port from your host network (your computer) to the container (application).

And that's it! You can access it on your favorite browser via 127.0.0.1:4533 or maybe on your LAN via whatever the private IP address you have (e.g 192.168.1.14:4533)

Image description

At first you need to create an admin user, so just pick your favorite username and a unique password!

Accessing Navidrome anywhere

Until now your Navidrome is accessible from your own computer and your Local Area Network (LAN). To access it anywhere, you have two choices:

  • Expose it to the internet a.k.a world wild web (WWW)
  • Use Virtual Private Network (VPN)

For the first option, I already wrote about it here. You can always refer to the official Cloudflare Tunnel docs here.

For the latter, let's begin with VPN crash courses. A VPN is an overlay network, meaning the network lives on another network (internet). For instance, a LAN is a network. If you want to access your computer on your LAN via another network (internet), that's what a VPN program does.

Don't be confused with commercial VPNs; while the underlying work is still the same, commercial VPNs sell "exit node" so all your traffic is routed through the exit node—in case you're not multi-hop—likely to prevent DPI and DNS Hijack.

Everyone's favorite VPN provider is Tailscale. Tailscale offers zero-config, as peer-to-peer as possible and end-to-end encryption via Wireguard protocols as its main feature. You have no idea how complex VPNs—or just any other software—actually are if you're using Tailscale.

The idea is simple: install Tailscale anywhere you want to access your devices. If you want to access Navidrome on your PC at home via an iPhone while at your favorite coffee shop, just install Tailscale on both your home PC and iPhone and it's done.

Image description

In the screenshot above I'm accessing my Navidrome on my Mac mini (heavy-rotation) at home via my phone while I'm at a random coffee shop in Jakarta writing this. In case anyone is asking I put a Reverse Proxy on every web service I use so I don't access the port directly and the screenshot is only for the sake of example and simplicity.

Tailscale will give you a free *.ts.net domain you can use so heavy-rotation.xxx.ts.net technically works but I'm too lazy to write it (and Tailscale manages "search domain" for me anyway).

While Tailscale uses end-to-end encryption, your browser may alert you if you're accessing an HTTP website outside the local network. In many cases, this is harmless. If you're annoyed, refer to Tailscale Serve to have Tailscale manage TLS certificates for you so your browser will be happy.

Managed Hosting

Navidrome also endorses managed hosting for anyone who don't want to manage their own server. On the other hand, you might consider Fly.io as well because it runs docker containers and turns them into something something Firecracker microVMs.

But here's the catch: say you already have thousands of music files maybe on your NAS, you're not going to bring your NAS to the cloud provider's data center, right?

You can establish a VPN connection to connect your home network to the cloud provider's, and most of the time it will work. However, nothing stops you from making it look like you're backing up your music collection offsite by... actually backing it up to the cloud. This is another story but it's just a free idea.

On another note, if you use my referral code to try Linode (a cloud provider) to run this thing, I can help you set it up and get it running, including the VPN installation.

Shameless Plug

If you came to this page from the flo landing page, you probably know the whole context.

If you didn't...

So I'm developing an application called flo, an iOS client for Navidrome. It's free, open-source and written in Swift. To learn more, visit this page.

While there are alternatives out there, I don't think they fit my preferences, from UIs and UXs to maybe some features. Also, this is my project in my free time and I use Navidrome whenever I plug in my airpods. It's a fun project that keeps me productive and joyful.

As of this writing, flo is not on the App Store yet due to my pending Apple Developer Program application. But we'll notify you as soon as possible if you're opted in to our waiting list!

EOF

I don't remember the last time I used Spotify or Apple Music and I don't think I regret the move.

But to be fair, I don't discover music that much, and my music taste is somewhat questionable. I don't care about my discover weekly or top mixes or the "made for you" playlists.

I do follow my favorite artists on social media to get their latest releases and maybe that's what social media is for.

One thing I miss is probably the lyrics. In many cases, I already remember the lyrics. In some cases, a search engine is an internet user's best friend. In rare cases, Karaoke mode — and I don't bring my phone while showering anyway. But I can't lie I miss shitposting lyrics that are unrelated to any particular events or moods and in fact the reason I post them is just because, why not?

flo, by the way, will shows lyrics in the future to fulfill my shitposting needs! The changes are already in my git stash, and it's about time to make them official!

To conclude, you can always refer to the official Navidrome Installation page.

Top comments (0)