How to use Plex and Ngrok together on MacOS
2 min read

How to use Plex and Ngrok together on MacOS

I've recently set on a quest to better protect and backup my family's photos and files. This post is a bonus part for that quest. Since I'm already dedicating disk space to store files, why not make them available in our TV and elsewhere?

So I decided to setup Plex in an idle machine I have at home. All went good, but through the regular installation our files would only be available through our local network. That's cool, for sure, but I also wanted to make them available to other people in our family, especially the ones that are not all that much tech savvy.

So I decided to setup a ngrok tunnel in order to reach the Plex media server directly. In addition to making stuff available elsewhere, this has the advantage that you don't have to care about opening ports in your router or worrying about security stuff. Ngrok will take care of taking external traffic and directing it to your local server.

Our end goal here is to have an externally accesable web url through which we can access our Plex server and have that working even with we restart the computer or close a terminal tab, for example.

How to do it

I'll assume at this point that you already have a Plex web server running. If you don't,  just head over to the official docs - they're super simple to follow. So let's start by installing ngrok:

brew install ngrok

Then, create a configuration file. Plex is currently using port 32400 to run the local server in my computer, so we'll use that. I've created my config file under the /Users/Documents/ngrok-config.yml location, but you can use any you want. Put this content in it:

authtoken: YOUR_NGROK_AUTH_TOKEN
tunnels:
web:
proto: http
addr: 32400

Then, install ngrok as a service:

sudo ngrok service install --config YOUR_PATH

Finally, start the service:

ngrok service start

To check it works, close the terminal tab you're working on and then head over the the Ngrok dashboard. Under the "Endpoints" tab you'll see the url for your tunnel. If you click it, you'll notice it'll open up the Plex media server page.

That wouldn't happen if you had to keep a terminal tab open for the ngrok process, so wohoo, success!

Hope it saves you some time!