On this page
- What should you plan for before installing Plex?
- How do you install Plex from the official repository?
- How can you tell the server is running?
- Why claim the server through an SSH tunnel?
- Which ports must be open?
- How do you lay out and upload media?
- How do you avoid transcoding on a CPU-only VPS?
- How do you update, back up and troubleshoot Plex?
- Questions
What should you plan for before installing Plex?
Three things shape a Plex server on a VPS: storage for the library, outgoing transfer for viewers, and CPU headroom for the rare transcode. Plex Media Server runs well in 2 GB of memory for a modest library; 4 GB helps during the first metadata scan of a large collection.
You also need a free Plex account, because the server is linked ("claimed") to an account before clients can find it. Some features, including hardware transcoding and certain remote playback options, depend on the paid Plex Pass or other subscriptions whose terms the vendor changes from time to time, so check the current plan details on the Plex site before you rely on them. Hardware transcoding would not help here anyway: our servers offer shared vCPUs and no GPU.
Only store and stream media you own or are licensed to share.
How do you install Plex from the official repository?
Plex publishes one APT repository for every Debian-based release. Add its key to a dedicated keyring and point a source file at it.
sudo apt update
sudo apt install -y curl gnupg ca-certificates
curl -fsSL https://downloads.plex.tv/plex-keys/PlexSign.key \
| sudo gpg --dearmor -o /usr/share/keyrings/plex.gpg
echo "deb [signed-by=/usr/share/keyrings/plex.gpg] https://downloads.plex.tv/repo/deb public main" \
| sudo tee /etc/apt/sources.list.d/plexmediaserver.list
sudo apt update
apt policy plexmediaserver
sudo apt install -y plexmediaserverIf the installer asks whether to keep or replace the repository file, keep the version you wrote. The package creates a plex system user and the plexmediaserver unit, and from now on Plex updates arrive with normal apt upgrade runs.
How can you tell the server is running?
Look at the unit and the listener on port 32400.
systemctl status plexmediaserver --no-pager
dpkg -l plexmediaserver | tail -n 1
sudo ss -tlnp | grep 32400
curl -s http://127.0.0.1:32400/identityThe identity call returns a small XML document with a machine identifier and the version string. Plex keeps its database, metadata and logs under /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/; the Logs folder there is the first stop when something misbehaves.
Why claim the server through an SSH tunnel?
Plex only offers the first-run setup to a browser it sees as local, which protects an unclaimed server from strangers. An SSH tunnel makes your laptop look local. Run this on your own computer, not on the server:
ssh -L 8888:127.0.0.1:32400 deploy@198.51.100.24While that session stays open, browse to http://localhost:8888/web, sign in with your Plex account, give the server a name and continue. After the claim finishes you can close the tunnel; from then on the server appears in every app signed in to the same account. Key-based logins make this smoother, see SSH keys and hardening.
Which ports must be open?
Clients outside the server connect to TCP 32400, so allow it along with SSH. The other Plex ports (DLNA, GDM discovery) serve home networks and can stay closed.
sudo ufw allow OpenSSH
sudo ufw allow 32400/tcp
sudo ufw enable
sudo ufw status numberedIn Settings, Remote Access, enable remote access and tick the option to specify the public port manually, entering 32400. With a dedicated IPv4 address and no NAT in front, the status should turn green within a minute. Plex issues its own certificate for *.plex.direct names, so app connections are encrypted without extra setup; set Secure connections to Required under Network to refuse plain HTTP.
How do you lay out and upload media?
Create library folders that the plex user can read, then copy files in from your computer.
sudo mkdir -p /srv/plex/movies /srv/plex/tv /srv/plex/music
sudo chown -R deploy:plex /srv/plex
sudo chmod -R 2775 /srv/plex
# on your computer
rsync -avP ./Movies/ deploy@198.51.100.24:/srv/plex/movies/Plex matches titles from folder and file names, so use Title (Year)/Title (Year).mkv for films and Show/Season 02/Show - s02e05.mkv for episodes. In the web app choose Add Library, pick the type, and add the matching folder. For long transfers, rsync can resume after a dropped connection.
How do you avoid transcoding on a CPU-only VPS?
Aim for direct play or direct stream on every device. A video transcode at 1080p can occupy most of a small plan, and several at once will stall.
- Store video as H.264 (or HEVC for clients that support it) with AAC or AC3 audio. Re-encode problem files once with FFmpeg on your own machine.
- In each client app, set the remote and local quality to Original or Maximum so the app does not request a lower bitrate.
- Use SRT subtitles; burned-in image subtitles force a transcode.
- Under Settings, Transcoder, keep the quality setting on Automatic and set a maximum number of simultaneous video transcodes, such as 1, to protect the rest of the server.
The Dashboard shows each active stream labelled Direct Play, Direct Stream or Transcode, which tells you which files to fix.
How do you update, back up and troubleshoot Plex?
Updates come from the repository: sudo apt update && sudo apt upgrade. For a backup, stop the service and archive the data folder, excluding the large Cache directory.
sudo systemctl stop plexmediaserver
sudo tar --exclude='*/Cache/*' -czf /root/plex-data.tar.gz \
-C /var/lib plexmediaserver
sudo systemctl start plexmediaserverIf remote access stays red, confirm the port with sudo ss -tlnp and test it from outside using the steps in blocked port checks. If a library shows empty, check ownership with sudo -u plex ls /srv/plex/movies.
Plans that fit this guide
Base city prices. Every plan includes a dedicated IPv4 address, IPv6, full root and all 18 images.
Questions about Plex Media Server
Is Plex Media Server free to run?
The server software is free to install and use for local libraries. Optional subscriptions add features; the exact list changes, so check the vendor's current terms.
Can I put Plex behind Nginx on port 443?
Yes. Proxy https://plex.example.net to http://127.0.0.1:32400 with WebSocket headers, then enter that URL under Network, Custom server access URLs. Many people keep direct 32400 access as well, since apps try both.
Why does the server not appear in my apps?
It was probably not claimed to the account you use in the app. Repeat the SSH tunnel step and sign in with that account at http://localhost:8888/web.
Will 4K files work?
Only when the client can direct play them. A CPU transcode from 4K HEVC is too heavy for a VPS, so keep a 1080p H.264 copy for devices that cannot decode the original.
How do I move Plex to a bigger plan later?
Deploy the new server, install Plex, stop it on both sides, copy the data folder and media with rsync, fix ownership to plex, then start it. The migration tutorial covers the general steps.