codex - 💡(How to fix) Fix Codex mobile shows macOS host offline/stuck when state_5.sqlite threads table is malformed

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Codex mobile Remote Control stopped working for a macOS Codex Desktop host that had worked the previous day. ChatGPT iOS showed the macOS host as offline / last seen hours ago, and later showed the same host with a spinner and loading placeholders. The macOS host was online, Codex Desktop was running, firewall was disabled, and the desktop app was up to date.

Local investigation found ~/.codex/state_5.sqlite is corrupt, specifically the threads table/indexes. Desktop logs repeatedly report sqlite state db unavailable while trying to update thread metadata. This appears to make mobile Remote Control surface a stale/offline/loading state instead of detecting local state DB corruption and showing a repairable error.

Error Message

Error: stepping, database disk image is malformed (11) *** in database main *** Tree 5 page 147: btreeInitPage() returns error code 11 Tree 36 page 129: btreeInitPage() returns error code 11 Tree 35 page 131: btreeInitPage() returns error code 11 Tree 34 page 34: btreeInitPage() returns error code 11 Tree 33 page 33: btreeInitPage() returns error code 11 Tree 24 page 24: btreeInitPage() returns error code 11 Tree 23 page 23: btreeInitPage() returns error code 11 Tree 22 page 22: btreeInitPage() returns error code 11 Tree 21 page 21: btreeInitPage() returns error code 11 Tree 20 page 20: btreeInitPage() returns error code 11 wrong # of entries in index idx_threads_archived_cwd_updated_at_ms wrong # of entries in index idx_threads_archived_cwd_created_at_ms wrong # of entries in index idx_threads_updated_at_ms wrong # of entries in index idx_threads_created_at_ms wrong # of entries in index idx_threads_provider wrong # of entries in index idx_threads_source wrong # of entries in index idx_threads_archived wrong # of entries in index idx_threads_updated_at wrong # of entries in index idx_threads_created_at wrong # of entries in index sqlite_autoindex_threads_1

Root Cause

Codex mobile Remote Control stopped working for a macOS Codex Desktop host that had worked the previous day. ChatGPT iOS showed the macOS host as offline / last seen hours ago, and later showed the same host with a spinner and loading placeholders. The macOS host was online, Codex Desktop was running, firewall was disabled, and the desktop app was up to date.

Local investigation found ~/.codex/state_5.sqlite is corrupt, specifically the threads table/indexes. Desktop logs repeatedly report sqlite state db unavailable while trying to update thread metadata. This appears to make mobile Remote Control surface a stale/offline/loading state instead of detecting local state DB corruption and showing a repairable error.

Code Example

Error: stepping, database disk image is malformed (11)
*** in database main ***
Tree 5 page 147: btreeInitPage() returns error code 11
Tree 36 page 129: btreeInitPage() returns error code 11
Tree 35 page 131: btreeInitPage() returns error code 11
Tree 34 page 34: btreeInitPage() returns error code 11
Tree 33 page 33: btreeInitPage() returns error code 11
Tree 24 page 24: btreeInitPage() returns error code 11
Tree 23 page 23: btreeInitPage() returns error code 11
Tree 22 page 22: btreeInitPage() returns error code 11
Tree 21 page 21: btreeInitPage() returns error code 11
Tree 20 page 20: btreeInitPage() returns error code 11
wrong # of entries in index idx_threads_archived_cwd_updated_at_ms
wrong # of entries in index idx_threads_archived_cwd_created_at_ms
wrong # of entries in index idx_threads_updated_at_ms
wrong # of entries in index idx_threads_created_at_ms
wrong # of entries in index idx_threads_provider
wrong # of entries in index idx_threads_source
wrong # of entries in index idx_threads_archived
wrong # of entries in index idx_threads_updated_at
wrong # of entries in index idx_threads_created_at
wrong # of entries in index sqlite_autoindex_threads_1

---

2026-05-17T19:28:50Z error [electron-message-handler] Request failed ... error={"code":-32603,"message":"failed to update thread metadata: thread-store internal error: sqlite state db unavailable for thread <redacted>"} method=thread/metadata/update
2026-05-18T02:11:59Z error [electron-message-handler] Request failed ... error={"code":-32603,"message":"failed to update thread metadata: thread-store internal error: sqlite state db unavailable for thread <redacted>"} method=thread/metadata/update
RAW_BUFFERClick to expand / collapse

Summary

Codex mobile Remote Control stopped working for a macOS Codex Desktop host that had worked the previous day. ChatGPT iOS showed the macOS host as offline / last seen hours ago, and later showed the same host with a spinner and loading placeholders. The macOS host was online, Codex Desktop was running, firewall was disabled, and the desktop app was up to date.

Local investigation found ~/.codex/state_5.sqlite is corrupt, specifically the threads table/indexes. Desktop logs repeatedly report sqlite state db unavailable while trying to update thread metadata. This appears to make mobile Remote Control surface a stale/offline/loading state instead of detecting local state DB corruption and showing a repairable error.

Environment

  • Codex Desktop: 26.513.31313 / bundle 2867
  • Bundled CLI: codex-cli 0.131.0-alpha.9
  • Host OS: macOS 26.3.1 (a) build 25D771280a
  • Host arch: arm64
  • Mobile: ChatGPT iOS Codex Remote Control
  • Host identity/IDs intentionally redacted

What happened

  1. Codex mobile Remote Control worked normally the previous day.
  2. The next day, ChatGPT iOS showed the macOS host as offline / last seen hours ago.
  3. Tapping reconnect did not restore it.
  4. Reopening the mobile surface later showed the host name with a spinner and loading placeholders.
  5. On the Mac, Codex Desktop was running and responsive.
  6. macOS firewall was disabled.
  7. The app bundle was current according to the appcast.
  8. Local remote-control enrollment still existed in ~/.codex/state_5.sqlite.
  9. lsof showed the Codex app server had outbound HTTPS connections; this did not look like a LAN listener/firewall issue.
  10. The failing local state DB was then checked directly with SQLite.

Diagnostics

sqlite3 ~/.codex/state_5.sqlite 'pragma integrity_check;' returns:

Error: stepping, database disk image is malformed (11)
*** in database main ***
Tree 5 page 147: btreeInitPage() returns error code 11
Tree 36 page 129: btreeInitPage() returns error code 11
Tree 35 page 131: btreeInitPage() returns error code 11
Tree 34 page 34: btreeInitPage() returns error code 11
Tree 33 page 33: btreeInitPage() returns error code 11
Tree 24 page 24: btreeInitPage() returns error code 11
Tree 23 page 23: btreeInitPage() returns error code 11
Tree 22 page 22: btreeInitPage() returns error code 11
Tree 21 page 21: btreeInitPage() returns error code 11
Tree 20 page 20: btreeInitPage() returns error code 11
wrong # of entries in index idx_threads_archived_cwd_updated_at_ms
wrong # of entries in index idx_threads_archived_cwd_created_at_ms
wrong # of entries in index idx_threads_updated_at_ms
wrong # of entries in index idx_threads_created_at_ms
wrong # of entries in index idx_threads_provider
wrong # of entries in index idx_threads_source
wrong # of entries in index idx_threads_archived
wrong # of entries in index idx_threads_updated_at
wrong # of entries in index idx_threads_created_at
wrong # of entries in index sqlite_autoindex_threads_1

The affected rootpages correspond to threads and its indexes.

Desktop logs contain repeated failures like this, with thread IDs redacted here:

2026-05-17T19:28:50Z error [electron-message-handler] Request failed ... error={"code":-32603,"message":"failed to update thread metadata: thread-store internal error: sqlite state db unavailable for thread <redacted>"} method=thread/metadata/update
2026-05-18T02:11:59Z error [electron-message-handler] Request failed ... error={"code":-32603,"message":"failed to update thread metadata: thread-store internal error: sqlite state db unavailable for thread <redacted>"} method=thread/metadata/update

A SQLite .recover against a snapshot of the DB completed successfully, and the recovered DB passes pragma integrity_check with ok. The recovered DB retained the remote_control_enrollments row. Recovery has not yet been applied to the live install at the time of filing.

Expected behavior

If Codex Desktop finds that state_5.sqlite is malformed or that threads is unavailable:

  • Desktop should surface a clear local recovery/repair message instead of leaving mobile to show the host as offline or stuck loading.
  • Mobile Remote Control should show a specific actionable error, for example that the desktop host is online but local state is corrupted/unavailable.
  • Codex should preserve the malformed DB, rebuild/recover from session JSONL where possible, and re-index threads automatically or via a visible repair action.
  • Remote-control host health should distinguish between transport/connectivity failure and local state-store failure.

Actual behavior

The phone shows the host as offline/stale or stuck loading, even though the desktop host is running. The local SQLite corruption is only discoverable by manually running pragma integrity_check and reading desktop logs.

Related issues

This looks related to both:

  • #20493, which reports corrupt state_5.sqlite causing desktop chats to disappear/blank.
  • #22773, which tracks broader iOS/macOS Remote Control stale/offline/hydration failures.

This report is narrower: a malformed threads table/indexes in state_5.sqlite appears to make mobile Remote Control present the macOS host as offline/stuck rather than reporting a local state-store failure.

Privacy note

This report intentionally omits account IDs, server/environment IDs, raw hostnames, screenshots, full local paths outside ~/.codex, and thread IDs.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

If Codex Desktop finds that state_5.sqlite is malformed or that threads is unavailable:

  • Desktop should surface a clear local recovery/repair message instead of leaving mobile to show the host as offline or stuck loading.
  • Mobile Remote Control should show a specific actionable error, for example that the desktop host is online but local state is corrupted/unavailable.
  • Codex should preserve the malformed DB, rebuild/recover from session JSONL where possible, and re-index threads automatically or via a visible repair action.
  • Remote-control host health should distinguish between transport/connectivity failure and local state-store failure.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Codex mobile shows macOS host offline/stuck when state_5.sqlite threads table is malformed