Codex App fails to launch after update on macOS: state runtime sqlite (state_5.sqlite) "database disk image is malformed"
What version of the Codex App are you using (From "About Codex" dialog)?
unknown — the app fails before the About dialog is reachable.
What subscription do you have?
Pro
What platform is your computer?
Darwin 24.6.0 arm64 arm
(MacBook Pro 14" 2024, Apple M4 Pro, 48 GB RAM, macOS Sequoia 15.7.3)
What issue are you seeing?
After updating the Codex App on macOS, the app fails to finish launching and shows a modal error dialog:
Codex cannot access its local database. The app cannot finish launching until its SQLite database is accessible. Database path: Path unavailable in app-server startup error Close other Codex applications, then click Retry to check whether access has been restored. Error: (code=1, signal=null). Most recent error: Error: failed to initialize sqlite state runtime under /Users/xxxx/.codex: failed to initialize state runtime at /Users/xxxx/.codex: error returned from database: (code: 11) database disk image is malformed
Clicking Retry reproduces the same error. Quit is the only way out; the app cannot be used at all.
Filesystem state under ~/.codex
The state runtime sqlite file referenced in the error exists, along with two other sqlite files:
| File | Size |
|---|---|
| state_5.sqlite | 315 KB |
| goals_1.sqlite | 24 KB |
| logs_2.sqlite | 956 MB |
logs_2.sqlite being ~1 GB looks abnormal; not sure whether the corruption is in state_5.sqlite (the file named in the error) or whether the oversized logs DB is contributing to the failure. Happy to upload a sqlite-integrity check report if useful.
What steps can reproduce the bug?
- Use the Codex App on macOS normally for some time (regular use over several weeks; sqlite files accumulate).
- Let the app auto-update (or update via the in-app updater) to the latest version.
- Relaunch Codex.
- The "Codex cannot access its local database" modal appears immediately on startup; Retry has no effect.
I cannot provide a session id, token limit usage, or context window usage — the app never reaches a state where any session is started.
What is the expected behavior?
- The app should launch normally after an update.
- If a state-runtime SQLite file is detected as corrupt, the app should either (a) auto-recover by quarantining the bad file and re-initializing, or (b) surface a clear remediation path (e.g. "rename
state_5.sqliteand restart") rather than wedging at startup with no actionable next step.
This is the same class of issue tracked in #21750 (no auto-recovery for a corrupt state_5.sqlite) — that issue's resolution would address this case too.
Additional information
- Same symptom reported by another macOS user in #24006 (also Darwin arm64). Filing separately, but treating these as likely the same root cause.
- Windows-side equivalents: #23780 (closed), #23923, #23893 — pattern of startup-blocking SQLite errors after updates appears cross-platform.
- #23848 claims to share a fix; if a documented workaround exists, please link it from this issue or pin it somewhere discoverable from the error dialog itself.
state_5.sqlitehas not been deleted/renamed — happy to keep it intact in case the team wants the corrupt file for diagnostics. Let me know if you'd like me to upload a sanitized copy.
6 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Update — workaround confirmed. Renaming the corrupt state DB and relaunching gets the app back to a working state:
Then quit and reopen Codex. The app rebuilds a fresh
state_5.sqliteon startup and launches normally.Confirmed on my setup (Darwin 24.6.0 arm64, M4 Pro, macOS 15.7.3, Pro plan). App is fully usable again.
A few notes for anyone hitting this:
.bakfile for at least a session or two in case you discover missing state (project metadata, threads, etc.) and want to extract anything viasqlite3 state_5.sqlite.bak ".recover". In my case nothing important seemed lost after the rebuild, but YMMV.logs_2.sqlite(956 MB in my case) was untouched by this workaround and the app launches fine with it in place — so the corruption that wedges startup really is isolated tostate_5.sqlite, not the oversized logs DB. That said, ~1 GB for a logs DB still looks like an unbounded-growth bug worth a separate look.state_5.sqliteis missing; it just doesn't handle the corrupt case. DetectingSQLITE_CORRUPT/database disk image is malformedat startup and quarantining the file (e.g. rename tostate_5.sqlite.corrupt-<timestamp>) before reinitializing would resolve this entire class of post-update startup failures with no user intervention.Hope this helps whoever lands here next while a proper fix is in flight.
For me it was the logs_2.sqlite that gave the crash. I renamed that one and it started working again
Proposed Solution: SQLite Corruption Auto-Recovery
Root Cause
StateRuntime::init_inner()handles missing databases (re-initializes) but does NOT handle corrupt databases — it hard-fails on any DB error includingSQLITE_CORRUPT/ "database disk image is malformed".Fix
.corrupt.{timestamp}.bak, re-initializePRAGMA integrity_checkbefore attempting to use the databaselogs_2.sqlitewith periodic VACUUMKey Code Change
Full solution:
solutions/codex-24030-sqlite-corruption-auto-recovery-fix.mdIt happens every time it autoupdates for me. Just discovered you can launch it from the command line, it'll prompt you to fix the database, then launch normally without loosing your data.
Workaround: reset Codex SQLite state
I ran into an issue where Codex could no longer open, and the root cause appeared to be related to its local SQLite state files.
The workaround that fixed it for me was:
.sqlitefiles under any.codexdirectory..sqlitefiles to keep them as backups, for example:After doing this, Codex was able to start normally again.
Note that this may reset some local Codex state, but the original SQLite files are still preserved as
.bakbackups in case they are needed later.