I need to know if it is possible to run Plex Media Server as a daemon on my Mac Mini. Because I need to buy a NAS for storage. I was gonna buy the Synology DS220J for storage and use the mac for the plex server. But if I can’t run as a daemon then I guess I better get the Synology DS220+ for both the NAS and Plex Server? I don’t know how well the DS220+ functions as a Plex Media Server compared to the Mac. I have a 2013 Intel 3770K processor , 16gb ram on my mac and it runs very well… like 10-20% CPU utilization max when transcoding to iOS plex client.
If AnyDesk can install itself as a service on Mac, then it is incomprehensible how Plex cannot.
I’d definitely upgrade again to a paid plan for this.
Did it work without having to log in?
Bumping this because it’s a really important feature. My Plex server becomes inaccessible if someone restarts the Mac while I’m away.
I’ve been trying to do this using Lingon and can’t seem to get it to work. Googling brings up all sorts of suggestions which don’t seem to work either. Is anyone aware of a way that does work, or do you happen to have this working and can share some insight?
My situation is that I can easily create the launch daemon using Lingon and even get Plex to launch, but when I then log out of that user account it’s no longer running.
There’s a version of Plex that runs on Synology NAS which is effectively headless. I wonder why this is hard ?
I would still like this feature as well. Surprised it hasn’t happened or at least at a minimum an explanation as to why it has not.
Bumping this up. There are multiple threads about this, but this is the most recent activity and a mod directed to this one.
I used Gemini to assist me with getting PMS to work at login, but it only works locally in a browser using the IP address (i.e. 192.168.x.x:32400/web) or from Nvidia Shield or Apple TV apps. I’m unable to access it remotely using app.plex.tv (it throws a “app.plex.tv is unable to connect to securely” error). It’s mostly there, but I want to make sure I can access it remotely. Gemini directed me to SSH into my Firewalla router and add the file ~/.firewalla/config/unbound_local/plex.direct with content:
server:
private-domain: “plex.direct”
but it didn’t work. It then wanted me to make networking changes to files in the Mac so I stopped there as I don’t want to disrupt MacOS files.
So I believe it is possible. I just don’t know how to get it working perfectly.
Here are the basic steps Gemini had me take:
Run the following command to create the file (you’ll need your Mac password): sudo nano /Library/LaunchDaemons/com.plexapp.mediaserver.plist
Content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.plexapp.mediaserver</string>
<key>ProgramArguments</key>
<array>
<string>/Applications/Plex Media Server.app/Contents/MacOS/Plex Media
<string>--watchdog</string>
Server</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
<key>StandardOutPath</key>
<string>/tmp/plex.log</string>
<key>StandardErrorPath</key>
<string>/tmp/plex.error.log</string>
<key>EnvironmentVariables</key>
<dict>
<key>HOME</key>
<string>/Users/YOURUSERNAME</string>
<key>PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR</key>
<string>/Users/YOURUSERNAME/Library/Application Support</string>
<key>PLEX_MEDIA_SERVER_PREFERENCES_FILE</key>
<string>/Users/YOURUSERNAME/Library/Preferences/com.plexapp.plexmediaserver.plist</string>
<key>PLEX_MEDIA_SERVER_USE_SECURE_CONNECTIONS</key>
<string>0</string>
<key>TMPDIR</key>
<string>/tmp</string>
</dict>
<key>UserName</key>
<string>YOUR_USERNAME</string>
</dict>
</plist>
For security, macOS requires that system-level daemons are owned by the “root” user.
-
Set the correct ownership:
sudo chown root /Library/LaunchDaemons/com.plexapp.mediaserver.plist -
Load the service:
sudo launchctl load -w /Library/LaunchDaemons/com.plexapp.mediaserver.plist
Turn off Open at Login in PMS.
Add your network IP range to List of IP addresses and networks that are allowed without auth in PMS > Settings (wrench) > Settings > Network
Change Secure connections to Preferred in PMS > Settings (wrench) > Settings > Network
Add your custom server URL (IP address of your server) to Custom server access URLs (i.e. 192.168.x.x:32400) in PMS > Settings (wrench) > Settings > Network. Note: also add https://app.plex.tv as I updated in the next post. That worked for me.
Give PMS Full Disk Access in MacOS Settings > Privacy & Security. Also add /bin/sh and /usr/sbin/launchd (this didn’t exist on my system) if they aren’t there.
Give PMS access to Local Network in MacOS Settings > Privacy & Security
Turn off Limit IP Address Tracking for the network you’re connected to (MacOS Settings > WiFi or MacOS Settings > Network)
Use a static IP for the network (set in your router).
Force macOS to Mount Disks at Boot
sudo defaults write /Library/Preferences/SystemConfiguration/autodiskmount AutomountDisksWithoutUserLogin -bool YES
Ensure the drive stays pinned to the system, not just the user:
sudo diskutil enableJournal /Volumes/[YourDriveName]
Since the system is launching this, you need to ensure the user has permission to run background tasks.
- Run:
sudo launchctl load -w /Library/LaunchDaemons/com.plexapp.mediaserver.plist
If you restart here and it fails (it failed for me) proceed:
We need to perform a Manual Claim by injecting your specific user credentials directly into the environment variables of your Launch Daemon.
Step 1: Get your Claim Token
-
Go to plex.tv/claim on any computer.
-
Copy the code (it starts with
claim-xxxxxxxx).- Note: This token expires in 4 minutes, so be ready to do the next step immediately.
Step 2: Inject the Token into your Daemon
-
On your Mac, open the daemon file:
sudo nano /Library/LaunchDaemons/com.plexapp.mediaserver.plist -
Inside the
<dict>forEnvironmentVariables, add thePLEX_CLAIMkey:
<key>EnvironmentVariables</key>
<dict>
<key>PLEX_CLAIM</key>
<string>claim-YOUR_TOKEN_HERE</string>
</dict>
Plex might be stubbornly holding onto old, invalid local security data. You can clear the local “online” identity while keeping your library intact:
defaults delete com.plexapp.plexmediaserver PlexOnlineHome
defaults delete com.plexapp.plexmediaserver PlexOnlineMail
defaults delete com.plexapp.plexmediaserver PlexOnlineToken
defaults delete com.plexapp.plexmediaserver PlexOnlineUsername
Run this command to allow your local network to bypass the auth check:
defaults write com.plexapp.plexmediaserver allowedNetworks "192.168.x.0/24"
Step 3: Refresh and Restart
-
Save and exit (Ctrl+O, Enter, Ctrl+X).
-
Unload and reload to trigger the claim:
Bash
sudo launchctl unload /Library/LaunchDaemons/com.plexapp.mediaserver.plist sudo launchctl load -w /Library/LaunchDaemons/com.plexapp.mediaserver.plist
After you do this try to connect to Plex by going to the IP address:32400/web. It won’t be working. Click on the wrench > Settings > General (may go there automatically) and click on Claim this Server.
That got it working for me except remote access and from app.plex.tv.
Update:
I just got it fully working, including from app.plex.tv. Follow all the directions above. What I did in addition is:
On my Firewalla, turn off Unbound and add a Custom DNS rule for plex.direct to the IP address of my server
In PMS, added https://app.plex.tv to Custom server access URLs in Settings > Network in PMS settings. Add this to my post above.
FYI, I don’t know if this will work with FileVault on. I suspect not, but since it’s working I’m not going to risk breaking it. Someone else please chime in if you test it or know.
Ultimate test was using my phone with WiFi off and was able to play media using the Plex app and via app.plex.tv in a browser using cellular data, and it worked!
One drawback I’m noticing so far is that PMS is not scanning my library automatically when there are changes to folder. So if I add anything I have to manually initiate scanning library files. Not that big of a deal, but a small negative nonetheless.