Note: This article is for Plex Media Server version 1.23.2 and newer. If using an earlier version, see our older instructions.
Though rare, it is possible for your main Plex Media Server database to become corrupted. For instance, it might happen if the computer is turned off without first quitting Plex Media Server. In such a situation, you can attempt to repair the database.
Tip!: It’s always a good idea make a backup copy of the database file before doing any work on it.
In many cases, you may also be able to restore a database copy that was backed up via the Scheduled Tasks feature.
The database file will be located at
/Plug-in Support/Databases/com.plexapp.plugins.library.db inside the main Plex Media Server data directory. The data directory location can vary by operating system and device. The commands listed below will assume the default server data directory locations.
Note: You can also simply delete the
com.plexapp.plugins.library.db database file while the Plex Media Server is not running. Restarting the server will then restore your server to a nearly-fresh install state. (i.e. You will lose your existing libraries and need to recreate them, but you won’t be affecting your content itself.)
Warning: With the instructions below, if you run all of the “Check for Corruption” instructions prior to running the “Run a Repair” instructions, you will receive errors related to steps 2 & 3 of the latter. That is expected and the errors won’t affect anything.
Related Page: Where is the Plex Media Server data directory located?
Related Page: Restore a Database Backed Up via 'Scheduled Tasks'
Plex Media Server includes its own SQLite command line interpreter. Due to customizations included in the Plex Database, the standard SQLite interpreter is not able to repair the Plex Media Server database. The interpreter can be activated by running the Plex SQLite executable found in the Plex Media Server installation folder which will open up a SQLite Shell. You can then run regular SQLite commands in the shell. Plex SQLite can also be used as a command line tool replacing the standard SQLite3 executable. The examples below are shown using Plex SQLite as a command line to match previous instructions. If you need assistance using Plex SQLite as a shell, please post your questions in our support forum.
Make sure you quit/exit your Plex Media Server so that it is not running. The following commands are run in the Command Prompt application. When running the commands, be sure to enclose paths in quotes to handle spaces in paths. First, simply switch over to the directory containing the database.
cd "%LOCALAPPDATA%\Plex Media Server\Plug-in Support\Databases"
We recommend making a copy of the database before making any changes.
copy com.plexapp.plugins.library.db com.plexapp.plugins.library.db.original
Check for Corruption
You can run commands to check how corrupt the database might be. Even if the results come back “OK”, it’s still possible for there to be issues with a database, though.
"C:\Program Files (x86)\Plex\Plex Media Server\Plex SQLite.exe" com.plexapp.plugins.library.db "PRAGMA integrity_check"
Attempt to Repair the Database
Even if the integrity check doesn’t return errors, it can still sometimes help to try and repair the database. With the Plex SQLite interpreter, you can easily attempt a repair with 1 command. Please note that this will output a lot of information to your screen. You can speed up the process by passing the output to a file instead of the screen. You can remove the “.output recover.out” portion if you really want to look at the lines of SQL statements. Please note that the contents of the output will look similar to the output from the .dump command mentioned further below, but it is not the same. DO NOT use this output file for any other reason. You may delete the output file once the recovery is done.
"C:\Program Files (x86)\Plex\Plex Media Server\Plex SQLite.exe" com.plexapp.plugins.library.db ".output recover.out" ".recover"
The above command will reassemble your database with all the valid data it can find in your file.
Manually Repair the Database
If you wish to try and “repair” the database manually as before, you can perform a dump followed by an import to get it back to normal.
"C:\Program Files (x86)\Plex\Plex Media Server\Plex SQLite.exe" com.plexapp.plugins.library.db ".output dump.sql" ".dump"
"C:\Program Files (x86)\Plex\Plex Media Server\Plex SQLite.exe" com.plexapp.plugins.library.db ".read dump.sql"
Prior to restarting your Plex Media Server, you should also delete (or backup and move elsewhere) the following two files if they exist alongside the original database:
Mac and Linux
The commands for macOS and Linux/NAS devices are similar to the Windows instructions above and would be performed using the Terminal/command line on those systems. You just change the path to the executable.
Default path to the executable:
"/Applications/Plex Media Server.app/Contents/MacOS/Plex SQLite"
- Linux (desktop):
- Synology (DSM 6):
"/var/packages/Plex Media Server/target/Plex SQLite"
- Synology (DSM 7):
On Linux, after repairing the database, please double check the permissions on the new database file. It should match the following:
- Desktop Linux:
- Synology (DSM 6):
- Synology (DSM 7):