How to Install Plex Media Server on Ubuntu 18.04 LTS Server or Desktop

This tutorial will be showing you how to install Plex media server on Ubuntu 18.04 LTS server/desktop. Plex is a free piece of software that allows you to organize your movies, TV shows, music and photos in one beautiful interface and stream those media files on your PC, tablet, phone, TV, Roku, etc on the network or over the Internet. Plex can be installed on Linux, FreeBSD, MacOS, Windows and various NAS systems.

Install Plex Media Server on Ubuntu 18.04

First, go to Plex server download page, select Linux and choose Ubuntu 14.04 or newer.

plex ubuntu 18.04

If you are going to install Plex on a headless Ubuntu 18.04 server, then you can go to your browser’s download history, then copy the Plex download link and use wget to download Plex from command line like below.


Once the Plex deb package is downloaded, cd to the download directory. For example, my Plex is downloaded to the Downloads directory under Home, so I run the following command. The tilde (~) represents home directory.

cd ~/Downloads

On Debian based Linux distros (Ubuntu, Linux Mint, etc), dpkg  is the standard command line tool to install deb packages. So run the following command to install the Plex deb package.

sudo dpkg -i plexmediaserver_1.13.5.5332-21ab172de_amd64.deb

The -i is short for --install. Note that when you type the following

sudo dpkg -i plex

You can press the Tab key, which will autocomplete the filename.

plex ubuntu install

Now Plex media server is installed. We can check its status with:

systemctl status plexmediaserver

As you can see, it’s running on my Ubuntu 18.04 system. (Press q to take back control of terminal.)

ubuntu server plex guide

If Plex media server isn’t running, you can start it with:

sudo systemctl start plexmediaserver

Enable Plex Repository

By enabling the official Plex repo, you can update Plex on Ubuntu with apt package manager. The Plex deb package ships with a source list file. To see a list of files installed from a package, run dpkg with -L flag.

dpkg -L plexmediaserver

Open this file with the following command.

sudo nano /etc/apt/sources.list.d/plexmediaserver.list

By default, its content is commented out. Uncomment the last line. (Remove the beginning # symbol).

plex ubuntu repo

Then save and close the file. To save a file in Nano text editor, press Ctrl+O, the press Enter to confirm. To exit, press Ctrl+X.  After that, run the following command to import Plex public key to apt package manager.

wget -q -O - | sudo apt-key add -

Now update software repository index.

sudo apt update

If you see the following message.

W: Conflicting distribution: public InRelease (expected public but got )

You can safely ignore it because it’s a warning, not an error. Plex repository is working fine for Ubuntu 16.04. You will see this message if you use Ubuntu 18.04. You need to wait for Plex developers to fix this problem. If you don’t like to see this message, then disable the Plex repository. You can re-enable this repo when a new version of Plex comes out.

Plex Media Server Initial Setup

If you run the following command:

sudo netstat -lnpt | grep Plex

You can see that Plex media server is listening on and

install plex media server ubuntu ppa

The web-based management interface is available at port 32400. The first time you configure Plex, you must visit Plex via or localhost:32400/web. If you installed Plex on your Ubuntu 18.04 desktop, then you can search Plex Media Manager in your application menu. It will take you to Plex web interface, which in turn will take you to because you need to sign in with a account.

plex on ubuntu server

Note that if Plex is installed on a remote Ubuntu 18.04 server, you need to set up a SSH tunnel by executing the following command on your local computer. Replace with the IP address of the remote Ubuntu server.

ssh -L 8888:localhost:32400

Then you can access Plex web interface via the following URL.


This HTTP request will be redirected to http://localhost:32400/web on the remote server through SSH tunnel. This SSH tunnel is only needed for the initial setup. After the initial setup, you can access Plex web interface via server-ip-address:32400. Replace server-ip-address with your real server IP address.

Once signed in, you will be redirected to localhost:32400 to do the initial setup.

install plex media server ubuntu 18.04

On the next screen, enter a name for your Plex server. Make sure Allow me to access my media outside my home is checked. Then click Next.

plex ubuntu 18.04 repository

Now you can add libraries. Click Add Library button.

plex ubuntu 18.04 server

Select a library type, then click browse for media folder button to add your media folders.

plex media server ubuntu 18.04 setup guide

Note that the plex user needs to have read and execute permission on your media directories. For example, my 2T external hard drive is mounted under /media/linuxbabe/ , which is owned by root. Users not in group root can’t access it, so I run the following command to give user plex read and execute permission. (I do not recommend changing ownership with chown or chgrp command. Using the setfacl command will suffice.)

sudo setfacl -m u:plex:rx /media/linuxbabe/

You may also need to assign permission on individual media directories like below.

sudo setfacl -m u:plex:rx /media/linuxbabe/directory-name

It can be tempting to add the recursive flag (-R), which gives plex read and execute permission on every file and sub-directory on the drive.

sudo setfacl -R -m u:plex:rx /media/linuxbabe/

If your external hard drive is only used for storing media files, then you can do so, but if you have sensitive files on the external hard drive, don’t do it.

Once you finish adding your media folders, click Next and then click Done.  You can always add more libraries later.

Redo the Initial Setup

If you made a mistake in the initial setup, you can delete the Preferences.xml file and start it over.

sudo rm /var/lib/plexmediaserver/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml

sudo systemctl restart plexmediaserver

Now visit localhost:32400/web again. Plex will tell you there’s an unclaimed server. Click claim it now.

Create Nginx Reverse Proxy.

If you prefer to use a domain name rather than typing http://localhost:32400 to access your Plex media server, then you need to set up a reverse proxy. We can use Nginx for this purpose. Install Nginx from the default Ubuntu software repository.

sudo apt install nginx

Then create a server block file for Plex.

sudo nano /etc/nginx/conf.d/plex.conf

Put the following lines into the file. Replace with your own domain name. Remember to create an A record for the sub-domain in your DNS manager. (If your ISP gives you a dynamic IP address rather than a static IP address, you need to set up dynamic DNS and port forwarding, or use PageKite. )

server {
      listen 80;

      location / {
          proxy_set_header Host $host;
          proxy_set_header X-Real-IP $remote_addr;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

          #upgrade to WebSocket protocol when requested
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "Upgrade";

Save and close this file. Then test Nginx configuration.

sudo nginx -t

If the test is successful, reload Nginx for the change to take effect.

sudo systemctl reload nginx

Now you can access Plex media server via

Create Apache Reverse Proxy

If you prefer Apache over Nginx, then install Apache web server by using the following command.

sudo apt install apache2

To use Apache as a reverse proxy, we need to enable the proxy modules and the header module.

sudo a2enmod proxy proxy_http headers proxy_wstunnel

Then create a virtual host file for Plex.

sudo nano /etc/apache2/sites-available/plex.conf

Put the following configurations into the file. Replace with your actual domain name. Don’t forget to create DNS A record for this sub-domain.

<VirtualHost *:80>
   ErrorDocument 404 /404.html

   #HTTP proxy
   ProxyPass / http://localhost:32400/
   ProxyPassReverse / http://localhost:32400/

   #Websocket proxy
   SSLProxyEngine on
   <Location /:/websockets/notifications>
        ProxyPass wss://localhost:32400/:/websockets/notifications
        ProxyPassReverse wss://localhost:32400/:/websockets/notifications

   Header always unset X-Frame-Options

Save and close the file. Then enable this virtual host.

sudo a2ensite plex.conf

Restart Apache

sudo systemctl restart apache2

Now you can access Plex media server using the domain name.

Enable HTTPS

To encrypt the HTTP traffic when you visit Plex server from outside, we can enable HTTPS by installing a free TLS certificate issued from Let’s Encrypt. Install Let’s Encrypt client (certbot) on Ubuntu 18.04. Python3-certbot-nginx is the Nginx plugin and python3-certbot-apache is the Apache plugin.

sudo apt install certbot python3-certbot-nginx python3-certbot-apache

If you use Nginx, then run the following command to obtain and install TLS certificate.

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d

If you use Apache, then run this command:

sudo certbot --apache --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d


  • --nginx: Use the nginx plugin.
  • --apache: Use the Apache plugin.
  • --agree-tos: Agree to terms of service.
  • --redirect: Force HTTPS by 301 redirect.
  • --hsts: Add the Strict-Transport-Security header to every HTTP response. Forcing browser to always use TLS for the domain. Defends against SSL/TLS Stripping.
  • --staple-ocsp: Enables OCSP Stapling. A valid OCSP response is stapled to the certificate that the server offers during TLS.

The certificate should now be obtained and automatically installed.

home media server plex

And you can access Plex web interface via HTTPS.

install plex media server ubuntu 18.04 linux

How to Upgrade Plex on Ubuntu 18.04

When a new version of Plex media server comes out, you can upgrade it by executing the following commands.

sudo apt update

sudo apt upgrade

Then restart Plex.

sudo systemctl restart plexmediaserver

I hope this tutorial helped you install Plex media server on Ubuntu 18.04. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂

Rate this tutorial
[Total: 30 Average: 4.5]

25 Responses to “How to Install Plex Media Server on Ubuntu 18.04 LTS Server or Desktop

  • Jonathan
    5 months ago

    Nice guide! Very thorough!

    For those setting up a Plex server not on localhost, the statement “After the intitial setup, you can access Plex web interface in the usual way.” is a little confusing. It might be clearer to say “After the initial setup, you can access Plex web interface using port 32400 on the IP address of the remote machine.”

    Also, for some reason when I tried an SSH proxy on OSX with “ssh x.x.x.x -L 8888:localhost:32400” the browser refused my connection. I used this command on a Linux box instead:

    ssh -NL 8888:localhost:32400 x.x.x.x

  • Thanks for this nice guide, it works. Just a question, I access it from Raspbian (on Rapsberry). Is there a way to avoid to open the SSH tunnel each time before accessing it? I mean a way to make it permanent.


    • The SSH tunnel is only needed for the initial setup. After the initial setup, you can access Plex web interface via server-ip-address:32400. Replace server-ip-address with your real server IP address.

  • One of the most thorough guides I have seen for Plex setup. The SSH tunnel was really helpful for me, as I installed on a headless Ubuntu 18.04 setup.

    For those using Windows as a client, you can install the


    command from “Git for Windows” (search on Google), and enabling the option to use Linux CLI tools in the Windows CMD prompt during setup.

    Thanks for the guide!

  • Super easy to follow and get up and running, thank you! I was afraid switching from Windows 7 as a media server to Ubuntu was going to be hard, several of your guides now have got me running smoothly!

  • Richard Ragon
    4 months ago

    Got a question on setfacl. I’m using a QNAP Nas server for ALL the files that my Plex is using.

    What permissions in file sharing do I need?

  • When I use the command

    ssh -L 8888:localhost:32400

    on a local Linux Mint computer, I get the following output:

    [email protected]'s password:

    . Whether I use the password for the remote linux or the local linux, I continue to get permission denied. I’m very confused by this step. For the initial command, I am using the correct IP address for the remote machine as verified by ifconfig.

    • I realized that by adding the user to the command, it works.

      ssh [email protected] -L 8888:localhost:32400

      However, after performing this succesfully I am not able to load the webpage. After I try to load the webpage each time the command prompt shows

      channel 3: open failed: connect failed: Connection refused

      Any thoughts?

    • That usually means Plex media server isn’t running. Please check

      sudo systemctl status plexmediaserver

      And see if Plex is listening on port 32400.

      sudo netstat -lnpt | grep Plex
      • The plex server is running and listening to port 32400 on localhost and 32401 on

        I couldn’t access a different server I had installed but figured out I needed to allow the connection through ufw. I’ve ensured I have done that for Plex too.

  • Thanks for this! Plex was one of the last pieces of switching my server from Windows 10 to Linux. It’s been challenging, but the reduced footprint on my ageing HP Gen 7 Microserver has been greatly appreciated!

  • great tutorial.
    I do not understand why you install reverse proxy, it is already integrated, loging to with your credential will show you all yours servers…

  • Bafplus
    1 month ago

    Whats the deal with updating?
    PMS is telling me there is a new version, so i did sudo apt update.
    I get the “Conflicting distribution….” error, as expected, but also NO new available version to update.

    So how do i update PMS to the recent new version?

    • The new version isn’t in the repository yet. If you can’t wait, you need to download the deb package from Plex download page and install it with dpkg, just like when you first install it. Then restart Plex.

  • Satonne
    2 weeks ago


    If you have this error when you try to connect to ssh -L 8888:localhost:32400
    connect failed: Connection refused

    Open SSH connection with putty and add a tunnel SSH Proxy directly with this configuration : in Category – Connexion – SSH – Tunnels : Less empty “Port forwarding” and “Add new forwarded port”
    Source port = 1080
    Under Destination : empty description – Dynamic and Auto

    Click Add and vérify forwarded port to 1080D
    After save your configuration !

    After add proxy configuration SOCKS 5 with 1080 port in your browser or windows proxy for exemple.

    Try to connect to or localhost:32401 !

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • If my answer helped you, please consider supporting this site. Thanks :)