# Plex Server crashes while optimizing DB

**URL:** <https://forums.plex.tv/t/plex-server-crashes-while-optimizing-db/816768>\
**Category:** Plex Media Server\
**Tags:** server-windows\
**Created:** [October 31, 2022, 8:29am UTC](https://forums.plex.tv/t/plex-server-crashes-while-optimizing-db/816768 "2022-10-31T08:29:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![yannw](https://avatars.discourse-cdn.com/v4/letter/y/aeb1de/32.png) [@yannw](https://forums.plex.tv/u/yannw)\
**Post date:** [October 31, 2022, 8:29am UTC](https://forums.plex.tv/t/plex-server-crashes-while-optimizing-db/816768/1 "2022-10-31T08:29:46Z")

</div>

Server Version#: 1.29.1.6316  
Player Version#: 4.87.2

i moved my plex installation to a new pc last year. since then i have a bad media library (see screenshot) which i can’t remove and this one let my plex server crash every time the db is optimized

 ![2022-10-31 09_19_38-Window](https://global.discourse-cdn.com/plex/original/4X/3/9/e/39e5cd76794b55243bf8c96f6cf1c18944995bf0.png)

i searched for repair commands but they didn’t help. how can i remove this bad library ?

---

<div class="post-metadata">

**Author:** ![yannw](https://avatars.discourse-cdn.com/v4/letter/y/aeb1de/32.png) [@yannw](https://forums.plex.tv/u/yannw)\
**Post date:** [October 31, 2022, 9:52am UTC](https://forums.plex.tv/t/plex-server-crashes-while-optimizing-db/816768/3 "2022-10-31T09:52:08Z")

</div>

Hi, it’s for docker and linux only. i’m running a windows server.

from a repair manual steps like recover or reindex fail:  
C:\Users\Administrator\AppData\Local\Plex Media Server\Plug-in Support\Databases\>sqlite3.exe “C:\Users\Administrator\AppData\Local\Plex Media Server\Plug-in Support\Databases\com.plexapp.plugins.library.db”  
SQLite version 3.39.4 2022-09-29 15:55:41  
Enter “.help” for usage hints.  
sqlite\> .recover  
SQL error: unable to open database file  
sqlite\> PRAGMA integrity\_check;  
ok

---

<div class="post-metadata">

**Author:** ![OttoKerner](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ottokerner/32/10079_2.png) [@OttoKerner](https://forums.plex.tv/u/OttoKerner)\
**Post date:** [October 31, 2022, 11:25am UTC](https://forums.plex.tv/t/plex-server-crashes-while-optimizing-db/816768/4 "2022-10-31T11:25:29Z")

</div>

Quite likely, your plex server was not shut down cleanly, or you made a copy of the [plex data folder](https://support.plex.tv/articles/202915258-where-is-the-plex-media-server-data-directory-located/) while the server was still running. Both can leave you with an unusable database file.

> `SQL error: unable to open database file`

This message is telling you that the database is either completely absent, or damaged beyond repair.  
You will have to go back to one of the backup copies: [https://support.plex.tv/articles/202485658-restore-a-database-backed-up-via-scheduled-tasks/](https://support.plex.tv/articles/202485658-restore-a-database-backed-up-via-scheduled-tasks/)

(But do perform the repair steps with this as well!)

---

<div class="post-metadata">

**Author:** ![yannw](https://avatars.discourse-cdn.com/v4/letter/y/aeb1de/32.png) [@yannw](https://forums.plex.tv/u/yannw)\
**Post date:** [October 31, 2022, 12:10pm UTC](https://forums.plex.tv/t/plex-server-crashes-while-optimizing-db/816768/5 "2022-10-31T12:10:38Z")

</div>

the last backups have all the same status and the bad library because it’s since last year ☹

---

<div class="post-metadata">

**Author:** ![OttoKerner](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ottokerner/32/10079_2.png) [@OttoKerner](https://forums.plex.tv/u/OttoKerner)\
**Post date:** [October 31, 2022, 12:11pm UTC](https://forums.plex.tv/t/plex-server-crashes-while-optimizing-db/816768/6 "2022-10-31T12:11:34Z")

</div>

Then I’m afraid the only option is to start from scratch.

---

<div class="post-metadata">

**Author:** ![yannw](https://avatars.discourse-cdn.com/v4/letter/y/aeb1de/32.png) [@yannw](https://forums.plex.tv/u/yannw)\
**Post date:** [October 31, 2022, 12:22pm UTC](https://forums.plex.tv/t/plex-server-crashes-while-optimizing-db/816768/7 "2022-10-31T12:22:36Z")

</div>

☹ that will be weeks of work to correct and assign the metadata.

---

<div class="post-metadata">

**Author:** ![OttoKerner](https://sea1.discourse-cdn.com/plex/user_avatar/forums.plex.tv/ottokerner/32/10079_2.png) [@OttoKerner](https://forums.plex.tv/u/OttoKerner)\
**Post date:** [October 31, 2022, 12:23pm UTC](https://forums.plex.tv/t/plex-server-crashes-while-optimizing-db/816768/8 "2022-10-31T12:23:45Z")

</div>

It is crucial to act as swiftly as possible when there is suspicion of database damage. If you wait too long, this is what happens.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [January 29, 2023, 12:24pm UTC](https://forums.plex.tv/t/plex-server-crashes-while-optimizing-db/816768/9 "2023-01-29T12:24:42Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
