Cannot claim Plex Server

Version: 1.42.2.10156-f737b826c

I cannot claim my local server. When I go to 10.0.1.10:32400/web/index.html I just get the loading bar with nothing ever showing.

After getting the email a couple of weeks ago I did change my account password. Then went to https://account.plex.tv/claim to get a code and entered into the “Claim Token” in the Edit Plex Application settings in TruNas (http://10.0.1.10/ui/apps/installed/stable/plex/edit)

I also tried http://10.0.1.10:32400/myplex/claim?token=YOUR_CLAIM_TOKEN_HERE

None of these are working.

Any help is appreciated.

From the time you got the claim token until you started the container, was it longer than 4 minutes?

The token is valid for 5 minutes from the time it’s generated

The container was running before I request the token. It is a few seconds between requesting it and adding it to the config.

I just tried with the docker not running when I add the token, then immediately start it, and I get the same results. I see the blue loading bar in Safari but the app never loads.

Go into the container (on the command line)

Depending on container,

  1. Shutdown Plex (inside the container only) but not the container itself
  2. now go to where the Preferences.xml file is
  3. With Plex stopped,
  4. Edit (vi, nano, etc) and remove the Name="value" pairs for:
    – PlexOnlineUsername
    – PlexOnlineMail
    – PlexOnlineToken
    – PlexOnlineHome
  5. Save the file

At this point, Preferences.xml is completely detached from your account but retains everything else

  1. Shut down the container.

  2. Go to Plex.tv/claim

  3. COPY the claim token

  4. PASTE it into the container configuration as usual

  5. Start the container.

Give it a moment to start up and negotiate new token and register the server in your account.

If it doesn’t work, please stop the container and manually make a tar.gz of the Logs directory and attach here.

I’m having a similar issue where after the password reset, I cannot see my library. I can get a token by going to account.plex.tv/claim, but I am not given an option to enter it in the settings. Based on various posts, if I select the settings icon (wrench) and go to the general settings, I should be given a prompt to enter my token, but I don’t get that option.

I’m running the latest version of Plex Server on Synology as of today. Please see the screenshot from my settings page:

That is not where the claim token is used.

Is the NAS running DSM 6 or DSM 7?

Is Plex Media Server installed via Synology Package Center or are you running it in Docker?

Option 1: Web Browser
Point a private/incognito window at the IP address of the NAS. For example, if the IP address is 10.1.2.3, use http://10.1.2.3:32400/web.

See if you can login, reach server settings, and claim the server. You should see your server name listed below the Plex Web section, and General under the server name.

Option 2: DSM 7, Uninstall/Reinstall
If the NAS is running DSM 7 and PMS is installed via Package Center (not Docker), then use FAQ 31: Reset / Reclaim PMS on DSM 7 (Not Authorized - Locked Out).

The process is straightforward. You uninstall Plex, then re-install using the Plex Claim Token. This is only for authentication/claiming. Your media files, Plex settings, etc. are not touched.

Option 3: User Credential Reset Utility
If running PMS in Docker, use the User Credential Reset utility. It also works for PMS installations using Package Center.

Download the script to the NAS, login via SSH and run it as root (see the readme on GitHub for details). You will be prompted for a Plex claim token.

I’m running DSM 7 and manually installed the Plex package on Synology, not docker. I’ll look at the faq you provided and see if I get my library back. Thank you.

If I ever change my password again, do I need to do this all over again? It feels unnecessarily cumbersome.

Use FAQ 31.

Yes. Changing your Plex account password unclaims your server.

1 Like

To add to FordGuy,

On DSM 7, Reclaiming your server should take no more than about 2 minutes most of which is copy & paste of the new token.

The Synology package does all the work for you.

Thank you. The first uninstall option on the FAQ didn’t work for me so I tried the second uninstall option and that worked.

I wish the Plex email that instructed me to change my password mentioned this FAQ. It’s really jarring when you open your client and don’t even see your media folders and no error message to point you in the right direction.

I agree the process was quick, however, it took me a very long time to find the reason for my missing files and find the procedure to get my server back.

Since I am the author and maintainer of the Synology package,
I’d like to ask:

Should I add a link or two to the Syno FAQ in the popup which everyone sees at the end of installation when installing PMS on DSM 7 ?

(the last thing you see before you click out of the Package Center – haha)

I have tried the steps listed, but I still cannot access my media. When I go to a browser and try to launch https:ip:32400/web it just sits with a blank screen.

When I try to access it via the Apple TV it does show me the list of shows we’ve been watching (which I’m guessing is stored on the Plex servers), but it just spins and won’t show any content.

I’m running TrueNAS Scale version: ElectricEel-24.10.2.4

Plex App version: 1.42.2.10156-f737b826c

Version: 1.2.16

Not sure where the logs are stored to see what they say.

@RcNorth

Can you get into the container ok from the SSH login?

I have a minimal TrueNAS machine (running on a NUC8-i7 box)

I’m pasting the entire log.

The TL;DR

  1. SSH into the TrueNAS
  2. Docker exec into the container
  3. Stop Plex
  4. From UserCredentialReset/UserCredentialReset.sh at main · ChuckPa/UserCredentialReset · GitHub
  5. Copy the script into a file (COPY/PASTE works well)
  6. Make it executable
  7. Run it
  8. Get token from plex.tv
  9. If successful, it responds with your email and plex username (see above)
root@truenas:/mnt/pool/chuck# docker container list
CONTAINER ID   IMAGE                                       COMMAND                  CREATED          STATUS                    PORTS     NAMES
09208fba707a   plexinc/pms-docker:1.42.2.10156-f737b826c   "/init"                  10 minutes ago   Up 10 minutes (healthy)             ix-plex-plex-1
root@truenas:/mnt/pool/chuck# docker exec -it ix-plex-plex-1 bash
root@truenas:/# cd /
root@truenas:/# ls
bin   config  dev  healthcheck.sh  init		     lib    libexec  mnt  plex-common.sh   proc  run   srv  tmp        usr  version.txt
boot  data    etc  home		   installBinary.sh  lib64  media    opt  plex_service.sh  root  sbin  sys  transcode  var
root@truenas:/# /plex_service.sh -d
root@truenas:/# cat > Reclaim.sh
#!/bin/sh
#
# Plex credential reset and claim for Plex Media Server
#
# Author:  ChuckPa
# Version: v1.11.0
#
#
Version="v1.11.0"
#
# Set Prefs
SetPref()
{
  # Add ONLY if it doesn't already exist
  if ! grep "$1" "$Preferences"  1>/dev/null 2>/dev/null ;  then
    sed -i "s;/>; $1=\""$2"\"/>;" "$Preferences"
  fi
}

# Determine which host we are running on and set variables
HostConfig() {

  # ASUSTOR
  if [ -f /etc/nas.conf ] && grep ASUSTOR /etc/nas.conf >/dev/null && \
     [ -d "/volume1/Plex/Library/Plex Media Server" ];  then

    # Where are things
    AppSuppDir="/volume1/Plex/Library"
    Preferences="$AppSuppDir/Plex Media Server/Preferences.xml"
    HostType="ASUSTOR"
    return 0

  # Synology (DSM 7)
  elif [ -d  /var/packages/PlexMediaServer ] && \
       [ -d "/var/packages/PlexMediaServer/shares/PlexMediaServer/AppData/Plex Media Server" ]; then

    # Where is the data
    AppSuppDir="/var/packages/PlexMediaServer/shares/PlexMediaServer/AppData"
    Preferences="$AppSuppDir/Plex Media Server/Preferences.xml"
    HostType="Synology (DSM 7)"
    StartCommand="/usr/syno/bin/synopkg start PlexMediaServer"
    StopCommand="/usr/syno/bin/synopkg stop PlexMediaServer"
    return 0

  # Synology (DSM 6)
  elif [ -d "/var/packages/Plex Media Server" ] && \
       [ -f "/usr/syno/sbin/synoshare" ]; then

    # Get shared folder path
    PlexShare="$(synoshare --get Plex | grep Path | awk -F\[ '{print $2}' | awk -F\] '{print $1}')"

    # Where is the data
    AppSuppDir="$PlexShare/Library/Application Support"
    Preferences="$AppSuppDir/Plex Media Server/Preferences.xml"
    HostType="Synology (DSM 6)"
    StopCommand="synopkg stop 'PlexMediaServer'"
    StartCommand="synopkg start 'PlexMediaServer'"
    return 0

  # QNAP (QTS & QuTS)
  elif [ -f /etc/config/qpkg.conf ]; then

    # Where is the software
    PKGDIR="$(getcfg -f /etc/config/qpkg.conf PlexMediaServer Install_path)"

    # Where is the data
    AppSuppDir="$PKGDIR/Library"
    Preferences="$AppSuppDir/Plex Media Server/Preferences.xml"
    HostType="QNAP"
    StartCommand="/etc/init.d/plex.sh start"
    StopCommand="/etc/init.d/plex.sh stop"
    return 0

  # Standard configuration Linux host
  elif [ -f /etc/os-release ]          && \
       [ -d /usr/lib/plexmediaserver ] && \
       [ -d /var/lib/plexmediaserver ]; then

    # Where is the data
    AppSuppDir="/var/lib/plexmediaserver/Library/Application Support"

    # Find the metadata dir if customized
    if [ -e /etc/systemd/system/plexmediaserver.service.d ]; then

      # Glob up all 'conf files' found
      NewSuppDir="$(cd /etc/systemd/system/plexmediaserver.service.d ; \
                    cat override.conf local.conf *.conf 2>/dev/null | grep "APPLICATION_SUPPORT_DIR" | head -1)"

      if [ "$NewSuppDir" != "" ]; then
        NewSuppDir="$(echo $NewSuppDir | sed -e 's/[^.]*SUPPORT_DIR=//' | tr -d \")"
        if [ -d "$NewSuppDir" ]; then
          AppSuppDir="$NewSuppDir"
        else
          echo "Given application support directory override specified does not exist: '$NewSuppDir'". Ignoring.
        fi
      fi
    fi

    Preferences="$AppSuppDir/Plex Media Server/Preferences.xml"
    HostType="$(grep ^PRETTY_NAME= /etc/os-release | sed -e 's/PRETTY_NAME=//' | sed -e 's/"//g')"
    StartCommand="systemctl start plexmediaserver"
    StopCommand="systemctl stop plexmediaserver"
    return 0

  # Netgear ReadyNAS
  elif [ -e /etc/os-release ] && [ "$(cat /etc/os-release | grep ReadyNASOS)" != "" ]; then

    # Find PMS
    if [ "$(echo /apps/plexmediaserver*)" != "/apps/plexmediaserver*" ]; then

      PKGDIR="$(echo /apps/plexmediaserver*)"

      # Where is the code
      AppSuppDir="$PKGDIR/MediaLibrary"
      Preferences="$AppSuppDir/Plex Media Server/Preferences.xml"
      HostType="Netgear ReadyNAS"
      StartCommand="systemctl start fvapp-plexmediaserver"
      StopCommand="systemctl stop fvapp-plexmediaserver"
      return 0
    fi

  # Western Digital  (watch for semi-broken configurations with multiple drives)
  elif [ -f /etc/system.conf ] &&  grep "Western Digital Corp" /etc/system.conf >/dev/null; then

      AppSuppDir="$(echo /mnt/HD/HD*/Nas_Prog/plex_conf)"
      for i in $AppSuppDir
      do
        if [ -f "$i/Plex Media Server/Preferences.xml" ];then
          AppSuppDir="$i"
          Preferences="$i/Plex Media Server/Preferences.xml"
          HostType="Western Digital"
          return 0
        fi
      done
      echo "ERROR: Host is Western Digital but Preferences.xml not found."

  # look for SNAP (low usage)
  elif [ -f "/snap/plexmediaserver/current/Plex Media Server" ] && \
       [ -f "/var/snap/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml" ]; then

      AppSuppDir="/var/snap/plexmediaserver/Library/Application Support"
      Preferences="/var/snap/plexmediaserver/Library/Application Support/Plex Media Server/Preferences.xml"
      HostType="Snap (Linux)"
      StartCommand="snap start plexmediaserver"
      StopCommand="snap stop plexmediaserver"
      return 0

  # Containers:
  # -  Docker cgroup v1 & v2
  # -  Podman (libpod)
  elif [ "$(grep docker /proc/1/cgroup | wc -l)" -gt 0 ] || [ "$(grep 0::/ /proc/1/cgroup)" = "0::/" ] ||
       [ "$(grep libpod /proc/1/cgroup | wc -l)" -gt 0 ]; then

    # HOTIO Plex image structure is non-standard (contains symlink which breaks detection)
    if [ -n "$(grep -irslm 1 hotio /etc/s6-overlay/s6-rc.d)" ]; then
      PLEX_SQLITE=$(find /app/bin/usr/lib/plexmediaserver /app/usr/lib/plexmediaserver /usr/lib/plexmediaserver -maxdepth 0 -type d -print -quit 2>/dev/null); PLEX_SQLITE="$PLEX_SQLITE/Plex SQLite"
      AppSuppDir="/config"
      Preferences="$AppSuppDir/Plex Media Server/Preferences.xml"

      if [ -d "/run/service/plex" ] || [ -d "/run/service/service-plex" ]; then
        SERVICE_PATH=$([ -d "/run/service/plex" ] && echo "/run/service/plex" || [ -d "/run/service/service-plex" ] && echo "/run/service/service-plex")
        HaveStartStop=1
        StartCommand="s6-svc -u $SERVICE_PATH"
        StopCommand="s6-svc -d $SERVICE_PATH"
      fi

      HostType="HOTIO"
      return 0

    # Docker (All main image variants except binhex and hotio)
    elif [ -d "/config/Library/Application Support" ]; then

      PLEX_SQLITE="/usr/lib/plexmediaserver/Plex SQLite"
      AppSuppDir="/config/Library/Application Support"
      Preferences="$AppSuppDir/Plex Media Server/Preferences.xml"

      # Miscellaneous start/stop methods
      if [ -d "/var/run/service/svc-plex" ]; then
        HaveStartStop=1
        StartCommand="s6-svc -u /var/run/service/svc-plex"
        StopCommand="s6-svc -d /var/run/service/svc-plex"
      fi

      if [ -d "/run/service/svc-plex" ]; then
        HaveStartStop=1
        StartCommand="s6-svc -u /run/service/svc-plex"
        StopCommand="s6-svc -d /run/service/svc-plex"
      fi

      if [ -d "/var/run/s6/services/plex" ]; then
        HaveStartStop=1
        StartCommand="s6-svc -u /var/run/s6/services/plex"
        StopCommand="s6-svc -d /var/run/s6/services/plex"
      fi
      HostType="Docker"
      return 0

    # BINHEX Plex image
    elif [ -e /etc/os-release ] &&  grep "IMAGE_ID=archlinux" /etc/os-release  1>/dev/null  && \
         [ -e /home/nobody/start.sh ] &&  grep PLEX_MEDIA /home/nobody/start.sh 1> /dev/null ; then

      PLEX_SQLITE="/usr/lib/plexmediaserver/Plex SQLite"
      AppSuppDir="/config"
      Preferences="$AppSuppDir/Plex Media Server/Preferences.xml"

      if grep rpcinterface /etc/supervisor.conf > /dev/null; then
        HaveStartStop=1
        StartCommand="supervisorctl start plexmediaserver"
        StopCommand="supervisorctl stop plexmediaserver"
      fi

      HostType="BINHEX"
      return 0
    fi

  fi

  # Unknown / currently unsupported host
  return 1
}

############################################### Begin here ####################################################

# Initialize
Manual=0
CustomPreferences=""
ClaimToken=""
Preferences=""
StopCommand=""
StartCommand=""
PRINTF="echo -n"
[ -e "/usr/bin/printf" ] && PRINTF="printf %s"


# Check username
if [ "$(id -u)" -ne 0 ]; then
  echo "ERROR:  This tool can only be run as the root/admin (or sudo root/admin) user"
  exit 1
fi

# Use any given command line options
while [ "$1" != "" ]
do

  # Manual path to Preferences.xml given
  if [ "$1" = "-p" ]; then

    # -p (preferences path) option
    if [ -f "$2" ]; then

      if grep ProcessedMachineIdentifier "$2" >/dev/null 2>/dev/null; then

        # Use this path.  It appears to be a Preferences.xml file
        CustomPreferences="$2"
        shift
        shift
      else
        echo "File '$2' does not appear to be a minimally valid Plex Preferences.xml file.  Cannot use.  Exiting."
        exit 1
      fi
    else
      echo "ERROR:  Cannot access given Preferences file '$2'."
      echo "Exiting."
      exit 1
    fi

    HostType="User-Defined"
    Manual=1

  # User supplied claim token on command line ?
  elif [ "$(echo $1 | grep 'claim-')" != "" ]; then

    ClaimToken="$1"
    shift

  # Unrecognized item on command line
  else
    echo "Error:  Unrecognized command line item '$1'- ignored."
    shift
  fi
done

# Get our config if not manual
if [ "$CustomPreferences" = "" ]; then

  if ! HostConfig; then
    echo " "
    echo "Unrecognized host type.  Cannot continue."
    echo "Consider using: '$0 -p /path/to/Preferences.xml' for manual override"
    exit 1
  fi
else
  Preferences="$CustomPreferences"
fi

echo " "
echo "          User credential reset & reclaim tool for Plex Media Server (Linux)  ($HostType)"
echo "                                     (Version: $Version)"
echo " "
echo "This utility will reset the server's credentials."
echo "It will next reclaim the server for you using a Plex Claim token you provide from https://plex.tv/claim"
echo " "

# Make sure curl exists
if ! command -v curl > /dev/null; then
  echo " "
  echo "This utility requires the 'curl' command which is not found."
  echo "Please install 'curl' or add it to 'path' if already installed."
  exit 1
fi

if [ ! -f "$Preferences" ]; then
  echo "ERROR:  Cannot find Preferences file at '$Preferences'. Exiting"
  exit 1
fi

# Annotate custom preferences usage
if [ "$CustomPreferences" != "" ]; then
  echo "Using given Preferences path:  '$CustomPreferences'"
fi

# Make certain PMS is stoppable or stopped
if [ "$StopCommand" = "" ] || [ $Manual -eq 1 ]; then \
  if [ $(ps -ef | grep  'Plex Media Server' | grep -v Preferences | grep -v grep | wc -l) -gt 0 ]; then
    echo "ERROR:  PMS is running.  Please stop PMS and try again"
    exit 1
  fi
fi

# Get owner UID:GID of Preferences.xml  (sed mucks with it on some machines)
Owner="$(stat -c '%u:%g' "$Preferences")"
Permissions="$(stat -c '%a' "$Preferences")"

# Ask for claim token
if [ "$ClaimToken" != "" ]; then
  echo "Using given claim token:  '$ClaimToken'"
  echo " "
else
  while [ "$ClaimToken" = "" ]
  do
    $PRINTF  "Please enter Plex Claim Token copied from http://plex.tv/claim : "
    read ClaimToken

    if [ "$(echo $ClaimToken | grep '^claim-' )" = "" ]; then

      # Not recognized claim token
      echo "Token not recognized.  Token should be 'claim-xxxxxx' form"
      ClaimToken=""
    fi
  done
fi

# Get existing ClientID (ProcessedMachineID) for use below
ClientId="$(cat "$Preferences"                          | \
            tail -1                                     | \
            sed -e 's/.*ProcessedMachineIdentifier="//' | \
            sed -e 's/".*//'                            )"

# Stop Plex
if [ "$StopCommand" != "" ]; then
  echo "Stopping PMS"
  $StopCommand
  Result=$?
  if [ $Result -ne 0 ]; then
    echo "Unable to stop Plex.  Error code $Result."
    echo "Aborting."
    exit 1
  fi
fi

# Give 5 seconds to stop
sleep 5

# Make certain PMS is stopped
if [ $(ps -ef | grep  'Plex Media Server' | grep -v Preferences | grep -v grep | wc -l) -gt 0 ]; then
  echo "ERROR:  PMS is still running.  Please stop PMS and try again"
  exit 1
fi

# Clear Preferences.xml
echo "Clearing Preferences.xml"
sed -i 's/ PlexOnlineToken="[^"]*"//'    "$Preferences"
sed -i 's/ PlexOnlineUsername="[^"]*"//' "$Preferences"
sed -i 's/ PlexOnlineMail="[^"]*"//'     "$Preferences"
sed -i 's/ PlexOnlineHome="[^"]*"//'     "$Preferences"
sed -i 's/ secureConnections="[012]"//'  "$Preferences"
sed -i 's/ AcceptedEULA="[01]"//'        "$Preferences"

# Get Credentials
echo "Getting new credentials from Plex.tv"
LoginInfo="$(curl -X POST -s \
                  -H "X-Plex-Client-Identifier: ${ClientId}" \
                  -H "X-Plex-Product: Plex Media Server"\
                  -H "X-Plex-Version: 1.1" \
                  -H "X-Plex-Provides: server" \
                  -H "X-Plex-Platform: Linux" \
                  -H "X-Plex-Platform-Version: $HostType $(uname -r)" \
                  -H "X-Plex-Device-Name: PlexMediaServer" \
                  -H "X-Plex-Device: $HostType" \
                  "https://plex.tv/api/claim/exchange?token=${ClaimToken}")"

# If errors, redo claim sequence
Result=$?
if [ $Result -ne 0 ]; then
  echo "ERROR: Could not get credentials from plex.tv (Error: $Result)"
  exit 1
fi

# Extract values
Username="$(echo "$LoginInfo" | sed -n 's/.*<username>\(.*\)<\/username>.*/\1/p')"
Email="$(echo "$LoginInfo" | sed -n 's/.*<email>\(.*\)<\/email>.*/\1/p')"
Token="$(echo "$LoginInfo" | sed -n 's/.*<authentication-token>\(.*\)<\/authentication-token>.*/\1/p')"

# Make certain we got valid data
if [ "$Username" = "" ] || \
   [ "$Email"    = "" ] || \
   [ "$Token"    = "" ]; then

  echo Incomplete credentials from Plex.tv
  echo "  Username: '$Username'"
  echo "  Email:    '$Email'"
  echo "  Token:    '$Token'"
  echo ""
  echo "Cannot continue"
  echo ""
  echo "Server credentials are cleared but server has not been reclaimed.  Claim manually"
  exit 1

fi

# Write info to Preferences and continue to start
SetPref PlexOnlineUsername           "$Username"
SetPref PlexOnlineMail               "$Email"
SetPref PlexOnlineToken              "$Token"
SetPref AcceptedEULA                 "1"
SetPref PublishServerOnPlexOnlineKey "1"

# We made it
echo "Claim completed without errors."
echo " Username: $Username"
echo " Email:    $Email"
echo " "

# Set the ownership (back) to what it was and guarantee read/write
chown $Owner "$Preferences"
chmod $Permissions "$Preferences"

# Remove existing certificate and let PMS pull fresh
# (harmless if cert unchanged but required if password change)
CertDir="$(dirname "$Preferences")/Cache"
rm -f "$CertDir"/*.p12

if [ "$StartCommand" != "" ]; then
  echo "Starting PMS"
  $StartCommand
  echo "Complete."
else
  echo "Complete.  You may restart PMS."
fi
root@truenas:/# chmod +x Reclaim.sh 
root@truenas:/# ./Reclaim.sh 
 
          User credential reset & reclaim tool for Plex Media Server (Linux)  (Docker)
                                     (Version: v1.11.0)
 
This utility will reset the server's credentials.
It will next reclaim the server for you using a Plex Claim token you provide from https://plex.tv/claim
 
Please enter Plex Claim Token copied from http://plex.tv/claim : claim-cxMk_Xvr4Zn1k6ChYzRr
Stopping PMS
Clearing Preferences.xml
Getting new credentials from Plex.tv
Claim completed without errors.
 Username: ChuckPA
 Email:    ChuckIsCrazy@loonies.com
 
Starting PMS
Complete.
root@truenas:/#