Plex with Mullvad

CONNECTIVITY

Last updated: 19 August 2021


Initial set-up for all operating systems

  1. Log in to your Mullvad account on our website.
  2. Click on Manage ports and WireGuard keys.
  3. Click on Select a city under "Port forwarding" and select the city that you connect to with Mullvad.
  4. Click on Select a key and select No key (only OpenVPN), or if you are using WireGuard protocol then select the WireGuard key that you are using.
  5. Click on Add port to add a port for using with Plex. The new port tag under "Active ports" includes the country, city and the port number (for example se-sto-12345) . You will need this number (12345) for later.
  6. Open the Mullvad app and reconnect to a VPN server.
  7. In the Mullvad app click on the gear icon > Preferences and enable Local network sharing.
  8. Open Plex.
  9. Click on Settings > Remote Access and enable Remote Access.
  10. Check the box next to Manually specify public port and enter the port number you were assigned, then click Apply.

Windows

Add a firewall rule

  1. Click on the Windows icon.
  2. Type wf.msc and hit Enter.
  3. Click on Inbound Rules.
  4. Under the Actions column, click on New Rule.
  5. Select Port, then click Next.
  6. Select TCP and Specific local ports.
  7. Enter the port number you were assigned, then click Next.
  8. Select Allow the connection, then click Next.
  9. Check the boxes next to Private and Public, then click Next.
  10. Enter a name, for example "Plex port XXXXX", then click Finish.

Add a forwarding rule

  1. Click on the Windows icon.
  2. Type cmd, then click Run as administrator.
  3. Type the following (replace xxxxx with the port number you were assigned), then hit Enter:
    netsh interface portproxy add v4tov4 listenport=xxxxx listenaddress=0.0.0.0 connectport=32400 connectaddress=127.0.0.1

Start the forwarding rule

These steps will start the forwarding rule when you log in to Windows.

  1. Open Notepad and paste the netsh command into it.
  2. Save the file as plex.bat
  3. Click on the Windows icon and type taskschd.msc and then hit enter.
  4. Click on Create basic task.
  5. Name it “Plex”, then click Next.
  6. Select When I log on, then click Next.
  7. Select Start a program, then click on Next.
  8. In the Program/script field, click on browse and add the plex.bat that you previously created, then click Next.
  9. Click Finish.
  10. Click Task Scheduler library.
  11. Double-click on Plex.
  12. Under General, select Run with highest privileges.
  13. Click OK to save the changes.

macOS

  1. Enable IP forwarding by opening a Terminal, and run this command:
    sudo sysctl -w net.inet.ip.forwarding=1
  2. To add a forwarding rule, copy the following command (which spans over two lines in this guide) as one long line and run it in the Terminal: echo "rdr pass inet proto tcp from any to any port xxxxx -> 127.0.0.1 port 32400" | sudo pfctl -ef - (replace xxxxx with the port number you were assigned).
  3. To add a persistent redirect rule, run these two commands (the second command spans over two lines in this guide):
    sudo su
    echo "rdr pass inet proto tcp from any to any port xxxxx -> 127.0.0.1 port 32400" >
    /etc/pf.anchors/plex
    (replace xxxxx with the port number you were assigned).
  4. To open or create the sysctl.conf file run this command:
    sudo nano /private/etc/sysctl.conf
  5. Add the following line to it:
    net.inet.ip.forwarding=1
  6. Press control + x and then hit y and Enter to save.
  7. To create a com.plex.pfctl.plist file, run this command:
    sudo nano /Library/LaunchDaemons/com.plex.pfctl.plist
  8. Paste the following into the file:
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE plist PUBLIC "-//Apple Computer/DTD PLIST 1.0//EN" "http://www.apple.com
    /DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Label</key>
    <string>com.plex.pfctl.plist</string>
    <key>Program</key>
    <string>/sbin/pfctl</string>
    <key>ProgramArguments</key>
    <array>
    <string>/sbin/pfctl</string>
    <string>-e</string>
    <string>-f</string>
    <string>/etc/pf.anchors/plex</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>LaunchOnlyOnce</key>
    <true/>
    </dict>
    </plist>
  9. Press control + x and then hit y and Enter to save.
  10. To open the pf.conf file run this command:
    sudo nano /etc/pf.conf
  11. Add the following to it:
    rdr-anchor "port32400"
    load anchor "port32400" from "/etc/pf.anchors/plex"
  12. Press control + x and then hit y and Enter to save.

Linux

Add a redirect rule by running the following code (replace xxxxx with the port number you were assigned):
sudo iptables -t nat -I PREROUTING -p tcp --dport xxxxx -j REDIRECT --to 32400

FAQ

Does it work with both OpenVPN and WireGuard?

Yes. If you use WireGuard, then you have to add the port next to the WireGuard key that the app is using.

(Windows) Plex shows that it's accessible for less than a second

Try to disable the firewall temporarily. In Windows: In the firewall settings right click on "Windows Defender Firewall" and select Properties, then set "Firewall state" to off on the three tabs Domain Profile, Private Profile and Public Profile. If that helps then turn it back on again and check that you added the rule correctly in the step above.

(Windows) I am not sure if the netsh command worked

Run the command netsh interface portproxy show all to see the added rule. To remove the rule(s) run netsh interface portproxy reset

(Windows) How to check that the port forwarding works?

Read our port forwarding guide.

Run the command netsh interface portproxy reset in an elevated command prompt.

Start iperf with the command iperf3 -s -p xxxxx

Use our Connection check (click on the "Port check" tab) to ensure that the port is open.

You can not connect to the SOCKS5 proxy's exit IP since SOCKS5 does not support port forwarding. Make sure that the proxy is disabled in your web browser.

(macOS) The Plex settings does not show the server settings and Remote Access.

Make sure that you have enabled Local network sharing in the Mullvad app. Try to quit Plex from the Plex icon in the macOS menu bar and start it again. Then click on the Plex icon and select "Preferences...".

Local clients can no longer connect to the Plex server

Make sure that Preferences > Local network sharing is turned on in the Mullvad app. If it does not help then select your network interface in the Plex settings under Settings > Network > Preferred Network Interface.