To set up a Plex server on a virtual private server (VPS), install Plex Media Server, give it access to your media, connect it to your Plex account, and allow remote playback. This creates an always-on personal streaming library without leaving a computer running at home.
Setting up Plex manually on Ubuntu 24.04 gives you control over the installation, media folders, permissions, and firewall rules. A preconfigured Plex template gets you to the setup screen faster because Plex is already installed. You’ll still need to upload your media, create libraries, and configure remote access, though.
Before you start streaming, check that the VPS has enough storage, monthly data transfer, and processing power for your needs. You’ll also organize your files, test playback, secure the server, monitor its resources, and fix common service, permission, storage, and connection failures.
What do you need before setting up a Plex server?
You need a ready-to-use Ubuntu VPS, Secure Shell (SSH) access, a Plex account, media files, and enough server resources to store and stream them.
Start by setting up your VPS. Note the server’s public Internet Protocol (IP) address, then sign in via SSH to confirm you can reach the server.
ssh username@your_server_ip
Replace username and your_server_ip with your own server details.
SSH gives you an encrypted command-line connection from your computer to the VPS. You’ll use it to install Plex and manage the server. Your account also needs permission to run sudo commands, since those commands change system-wide settings.
Once you can connect successfully, check that the server meets the remaining requirements:
|
Requirement |
What to check |
|
Operating system |
The server is running 64-bit Ubuntu 24.04 |
|
Random access memory (RAM) |
At least 4 GB is available – more if you’ll run other software alongside Plex |
|
Central processing unit (CPU) |
Enough processing power for any video conversion Plex performs |
|
Storage |
Enough free space for media files, Plex library data, artwork, logs, and temporary files |
|
Network |
Outbound speed and monthly data transfer cover your expected streams |
|
Plex account |
You have an account to connect and manage the server |
|
Media files |
You hold the rights to the movies, shows, music, or photos you plan to store and stream |
Once you can connect to the VPS, check its processor power, network capacity, and storage. These resources set the practical limits on how much media you can store, how many streams the server can handle, and whether playback runs without buffering.
Processor use depends on whether Plex can play the original file. With Direct Play, Plex sends the file unconverted, so the server does very little processing.
If the viewing device doesn’t support the file or the connection can’t handle its original quality, Plex might transcode it by converting the video, audio, or resolution during playback. Transcoding uses much more CPU power and temporary disk space.
Don’t assume that a standard VPS includes compatible graphics hardware for faster transcoding. Hardware-accelerated streaming requires supported hardware and an active Plex Pass. Without it, the CPU handles the conversion.
The network matters just as much. Outbound speed determines whether each stream can play without buffering, while the plan’s monthly data allowance determines how much media the VPS can send in total. Storage must also leave room for Plex’s database, artwork, logs, and temporary transcoding files, not just your movies and shows.
Before choosing a VPS provider, check that it allows this type of use and supports the network access Plex needs. Plex licenses its server software for personal use, expects it to run on a home network, and notes that it might not work with every online hosting provider.
Important
Important! A VPS isn’t on the same local network as your viewing devices, so Plex treats video playback from it as remote. Remote personal video playback requires Plex Pass on the server administrator’s account, Plex Pass on the viewer’s account, or Remote Watch Pass on the viewer’s account. Music through Plexamp and photos through Plex Photos aren’t covered by this restriction.
How to set up a Plex server manually on Ubuntu
Set up Plex manually on Ubuntu 24.04 by installing Plex Media Server, creating media folders it can access, connecting your Plex account, and allowing remote connections.
1. Update the Ubuntu server
Start by updating your Ubuntu server:
sudo apt update sudo apt upgrade -y
The first command refreshes Ubuntu’s list of available packages. The second installs the latest versions.
Ubuntu might install a new Linux kernel during the upgrade. If it does, restart the VPS:
sudo reboot
The restart will close your SSH connection. Wait for the server to come back online, then reconnect before continuing.
2. Add the Plex repository and install Plex Media Server
Ubuntu needs to know where to download Plex and how to confirm that the package came from Plex.
A software repository is an online source that Ubuntu can pull packages from and verify using a signing key. Adding Plex’s repository also lets later public Plex releases arrive through Ubuntu’s normal package manager.
Install the tools needed to add the repository:
sudo apt install -y curl gnupg2 sudo install -d -m 0755 /etc/apt/keyrings
Download the Plex signing key:
curl -L https://downloads.plex.tv/plex-keys/PlexSign.v2.key | sudo gpg --yes --dearmor -o /etc/apt/keyrings/plexmediaserver.v2.gpg
The signing key lets Ubuntu verify that Plex published the package and that it hasn’t been changed after release.
Add the official Plex repository:
echo "deb [signed-by=/etc/apt/keyrings/plexmediaserver.v2.gpg] https://repo.plex.tv/deb/ public main" | sudo tee /etc/apt/sources.list.d/plex.list
Refresh the package list again and install Plex Media Server:
sudo apt update sudo apt install -y plexmediaserver
Once the installation finishes, Ubuntu can install future public Plex releases through its usual package update process.
3. Start Plex and check that it’s running
Plex runs in the background as a Linux service. A service is a program that keeps running after you close your SSH session. Ubuntu uses systemctl to manage Linux services, including starting, stopping, and checking their status.
Enable Plex and start it immediately:
sudo systemctl enable --now plexmediaserver
The enable part tells Ubuntu to start Plex whenever the VPS boots. The –now part starts it without waiting for the next restart.
Check whether the service is active:
sudo systemctl is-active plexmediaserver
A working installation returns:
active
You’re ready to continue when you see that result.
If the command returns inactive or failed, inspect the service status and recent log messages:
sudo systemctl status plexmediaserver sudo journalctl -u plexmediaserver -n 50 --no-pager
Look near the bottom of the output. A missing file, permission failure, or port conflict will usually appear there.
4. Create folders Plex can access
Plex runs under its own Linux account, named plex. Your SSH account uploads the files, while the plex account reads them during library scans and playback.
Both accounts need access to the same media folders. Placing them in a shared Linux group gives them that access without making the files writable by every account on the server.
Create a group named media, then add Plex and your current login account:
sudo groupadd --force media sudo usermod -aG media plex sudo usermod -aG media "$USER"
Create a separate folder for each media type:
sudo mkdir -p /srv/plexmedia/Movies "/srv/plexmedia/TV Shows" /srv/plexmedia/Music
Set your current user as the owner and media as the shared group:
sudo chown -R "$USER":media /srv/plexmedia
Adjust the folder and file permissions for Plex:
sudo find /srv/plexmedia -type d -exec chmod 2775 {} ;
sudo find /srv/plexmedia -type f -exec chmod 664 {} ;
These settings let your account upload and organize files while giving Plex access to the library. The leading 2 in 2775 also makes new subfolders inherit the media group, so Plex is less likely to lose access as the library grows.
Restart Plex after changing its group membership:
sudo systemctl restart plexmediaserver
Disconnect and reconnect your SSH or file-transfer session as well. Linux applies your own new group membership when you sign in again.
Check the Plex Support page for more guidance regarding Linux file and directory permissions.
Test the TV folder through the same account Plex uses:
sudo -u plex ls "/srv/plexmedia/TV Shows"
No output is fine if the folder is empty. A Permission denied message means Plex still can’t access the path.
5. Upload and organize your media
Use Secure File Transfer Protocol (SFTP) to transfer your media files securely.
SFTP sends files through the same encrypted connection as SSH. Upload each media type to its matching folder:
- Movies:
/srv/plexmedia/Movies - TV shows:
/srv/plexmedia/TV Shows - Music:
/srv/plexmedia/Music
Plex uses folder and file names to work out what each item is. Clear naming helps it find the correct title, poster, summary, cast, and episode information.
Give each movie its own folder and include the release year:
/srv/plexmedia/Movies/ └── Arrival (2016)/ └── Arrival (2016).mkv
For a TV series, use a show folder, season folder, and sXXeXX episode number:
/srv/plexmedia/TV Shows/
└── Severance (2022)/
└── Season 01/
└── Severance (2022) - s01e01.mkv
In s01e01, s01 means season 1 and e01 means episode 1.
Don’t mix movies and TV shows in the same library folder. Plex scans each media type differently, so mixing them can cause incorrect matches or make files disappear from the library scan.
After uploading a large batch, check how much disk space remains:
df -h /srv/plexmedia
Check the Avail column to see how much space remains.
Don’t fill the disk completely. Plex also needs space for its library database, downloaded artwork, logs, and temporary files created during transcoding. By default, Plex keeps its transcoding files on the operating system disk.
6. Open Plex through an SSH tunnel
Plex expects its first setup connection to come from the server itself or the same local network.
Your VPS is in a data center, so your computer isn’t on that local network. An SSH tunnel solves this by securely forwarding a browser connection from your computer to Plex on the VPS.
Open a new terminal on your computer and run:
ssh -L 8888:127.0.0.1:32400 YOUR_USER@SERVER_IP
Replace:
YOUR_USERwith your VPS usernameSERVER_IPwith your VPS IP address
The two port numbers have different jobs:
8888is a temporary port on your computer.32400is the port Plex uses on the VPS.
Keep the terminal open. Closing it also closes the tunnel.
Now enter this address in your browser:
http://127.0.0.1:8888/web
Your browser connects to port 8888 on your computer. SSH then carries that traffic securely to port 32400 on the VPS.
Plex only requires this tunnel during the initial setup. Once the server is connected to your account, you can access it through the regular Plex Web App.
Sign in to your Plex account and follow the setup screen.
Connecting the server to your account is also called claiming the server. Claiming tells Plex which account owns the server and has permission to change its settings.
7. Add your media libraries
A Plex library is a collection for one type of media, such as movies, TV shows, or music.
During the setup screen, give the server a distinctive name – this is what shows up in the Plex app’s server list. Then, select Add Library → Movies, TV Shows, or Music. Browse to the matching server folder. Then repeat the process for the other media types.
Use these paths:
|
Plex library |
Server folder |
|
Movies |
|
|
TV shows |
|
|
Music |
|
Don’t select /srv/plexmedia as one combined library. Plex needs to know which scanning rules to use for each folder.
After you add a library, Plex scans its files and downloads metadata. Metadata is the extra information shown around a file, including its poster, title, summary, cast, and episode details.
Check several items after the scan finishes. If Plex selects the wrong movie or show, check the file name and release year first. Plex relies on properly separated and named media folders to match files correctly.
8. Allow remote connections
Plex uses Transmission Control Protocol (TCP) port 32400 for its main server connection. Opening only this port lets Plex apps reach the server without exposing anything else running on it.
Ubuntu uses a firewall tool called Uncomplicated Firewall (UFW). It comes pre-installed on most Ubuntu 24.04 images but is disabled by default – install it if your provider’s image doesn’t include it:
sudo apt install -y ufw
Allow SSH before enabling the firewall. Otherwise, you could block the connection you use to manage the VPS:
sudo ufw allow OpenSSH sudo ufw allow 32400/tcp sudo ufw enable sudo ufw status
Type y when Ubuntu asks whether to enable UFW.
The output should list both SSH and 32400/tcp as allowed.
If you changed the default SSH port, allow that custom port before enabling UFW instead of relying only on the OpenSSH rule.
These rules configure your Ubuntu firewall to accept Plex traffic while leaving its optional local-network ports closed. Plex recommends opening only TCP port 32400 when the server has a public IP address.
Your hosting provider might also have a network firewall outside Ubuntu. UFW controls traffic after it reaches the VPS, while the provider firewall controls whether that traffic reaches the VPS at all.
If your provider blocks incoming connections by default, add an inbound TCP rule for port 32400 there as well.
Enable remote access in Plex:
- Open Settings in the Plex Web App.
- Select Remote Access under the server settings.
- Click Enable Remote Access.
- Wait for Plex to test the connection.
If the test fails, enable Manually specify public port, enter 32400, and try again.
A successful test shows Fully accessible outside your network.
Test the server from a phone or another device that isn’t connected to your current network.
While a video plays, open the Plex dashboard and check the playback type:
- Direct Play means Plex sends the original file unchanged.
- Direct Stream means Plex repackages the file but doesn’t convert the video.
- Transcode means Plex converts part or all of the file during playback.
Plex chooses the mode based on the original file and the formats supported by the receiving device.
If playback buffers and the dashboard show transcoding, check the VPS CPU use. A server that stays near full CPU might need more processing power, lower playback quality, or files that the receiving device can Direct Play.
How to set up Plex faster with a VPS template
You can set up Plex faster with Hostinger’s Plex VPS template, which installs Ubuntu 24.04 and Plex Media Server for you.
Available with our Plex VPS hosting plans, the template skips the repository setup, package installation, and service configuration required by the manual method.
Follow the Plex VPS template setup instructions to select it in hPanel, connect to Plex through an SSH tunnel, and complete the initial setup.
The template also creates /home/plexlibrary/ for your media. Upload your files there through Secure File Transfer Protocol (SFTP), then add the corresponding folders as Plex libraries.
Plex comes preinstalled, but you still need to connect your account, organize your media, configure remote access, and keep the VPS updated.
Important
Important! Applying the template to an existing VPS reinstalls its operating system and deletes the data stored on it. Back up your VPS files you need before switching the OS.
What are the benefits of running Plex on a VPS?
A VPS keeps your Plex library available without requiring a home computer to stay powered on.
- The server stays online independently. Restarting or turning off your personal computer won’t take Plex offline.
- You don’t need to configure a home router. The VPS already has a public IP address, although you still need to allow Plex through its firewalls.
- Your home upload speed isn’t involved. Media leaves the data center where the VPS runs rather than passing through your home internet connection.
- You can choose the server location. Placing the VPS closer to its regular viewers reduces the distance each stream has to travel.
- You can increase resources later. A larger library or more simultaneous viewers might require more storage, CPU power, RAM, or monthly data transfer.
- Your media stays in one library. Plex organizes movies, shows, music, and photos in one place, available through supported apps connected to your account.
However, a VPS isn’t the right fit for every Plex library.
Large media collections can make hosted storage expensive, and several high-quality streams add up in monthly data transfer fast.
Don’t assume that a VPS includes a compatible graphics processing unit (GPU) for hardware-assisted transcoding. Hardware-accelerated streaming requires an active Plex Pass.
A standard VPS works best when most viewing devices can use Direct Play and the library fits within the plan’s storage and data-transfer limits.
How do you keep a Plex server secure and responsive?
Keep your Plex server secure and responsive by limiting access, installing updates, monitoring resources, and backing up its data.
- Secure the VPS itself. Use SSH keys, disable root login, remove unused services, configure a firewall, and monitor server logs.
- Protect your Plex account. Use a unique password and enable two-factor authentication, so a stolen password isn’t enough to sign in.
- Install updates regularly. Because you added the Plex repository, Ubuntu can update Plex along with the other installed packages:
sudo apt update sudo apt upgrade -y
- Keep the firewall narrow. Allow your SSH port and TCP port
32400. Don’t expose Plex’s optional discovery ports on a public VPS. - Watch the server during playback. Monitor your server’s performance while one or more videos play. High CPU use during a stream usually means Plex is transcoding.
- Leave free disk space. A full disk can interrupt scans, updates, logging, and transcoding. Converting media for multiple viewers at once often uses several gigabytes of temporary space.
- Back up the Plex data directory. On Ubuntu, Plex stores its database, settings, artwork, and viewing information here:
/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/
This directory doesn’t contain the movie or music files themselves. It contains the information Plex uses to organize them. Back it up separately from your media so you don’t have to rebuild every library match and setting after a server failure.
How do you fix common Plex server setup problems?
Start troubleshooting with the Plex service, folder permissions, port 32400, and current server resource use.
|
Symptom |
What to check |
What to do |
|
The setup page won’t open |
Plex service and SSH tunnel |
Run |
|
Plex shows an empty library |
Folder path and permissions |
Confirm the path and run |
|
Plex identifies the wrong title |
Folder and file names |
Add the movie’s release year or use |
|
Remote access remains unavailable |
UFW and the provider firewall |
Allow TCP port |
|
Remote video won’t play |
Plex account requirements |
Confirm that the server administrator or viewer has the required Plex subscription |
|
Playback buffers |
CPU use, network speed, and playback type |
Check whether Plex is transcoding, then lower the quality or use a Direct Play format |
|
New files don’t appear |
Library scan and permissions |
Scan the library again and confirm that the |
|
Plex stops after an update |
Service logs |
Run |
If the setup page won’t load, check that the Plex service is active before changing firewall rules. An open port won’t help when the application behind it isn’t running.
If Plex can’t see your files, test the folder as the plex user. This tells you whether the failure is due to Linux permissions or an incorrect library path.
If remote access fails, check both firewall layers. Opening the port in Ubuntu won’t help if your hosting provider’s network firewall still blocks it.
If playback stutters, open the Plex dashboard before upgrading the VPS. Direct Play with low CPU use points toward a network limit. Sustained high CPU during transcoding points toward a processing limit.
Manual installation gives you the most control over packages, folders, and permissions. The preconfigured template gets Plex running faster. Both methods still need enough storage, readable media folders, restricted network access, and server resources that match your expected streams.
All of the tutorial content on this website is subject to
Hostinger’s rigorous editorial standards and values.
Apply for Premium Hosting
Source Credit: https://www.hostinger.com/in/tutorials/how-to-set-up-plex-server/
