Shipping an AI app or agent? Security review in 1 working day: $149 / ₹13,900. Request a review →
AI Review Ready
Home / Error fixes / Peer closed MessagePort connection
Fix · Codex desktop · Windows

Codex: Peer closed MessagePort connection

Fix (reported by users, not official): this usually follows a message with many or large images that never sent. It stays in a local queue, and every later send crashes. Remove that unsent message: in the app if you can open its chat, or, with the app closed and a backup made, empty the queued-follow-ups entry in %USERPROFILE%\.codex\.codex-global-state.sqlite.

At a glance
ErrorA JavaScript error occurred in the main process / Uncaught Exception: Error: Peer closed MessagePort connection.
ToolCodex in the ChatGPT (Codex) desktop app. Most reports are from Windows (Microsoft Store package OpenAI.Codex 26.1117 and 26.1120); macOS too
Common triggerSending, pasting or dropping many or large images. Reports: 10 to 151 images, 257 to 466 MiB of queued data
Log lineRangeError: Message exceeds the 536870912-byte serialization limit.
FixRemove the unsent message: in the app if it opens, or empty queued-follow-ups in .codex-global-state.sqlite after a backup
StatusReported by users, not official. No OpenAI reply on GitHub as of 4 Dec 2026
Checked4 Dec 2026, against the sources listed below

Fix it

These steps come from users who recovered on Windows and macOS (issues #64073, #63217, #63610, #63104). OpenAI has not confirmed them.

  1. Quit the app completely. Close it from the system tray too, not just the window.
  2. Try the gentle fix first. If you can still open the chat where you attached the images, remove the unsent attachments and the draft there. One user did only this, without touching any files, and the queued data dropped from 317.5 MiB to 34.2 MiB. Text messages then worked again.
  3. If the app crashes before you get there, check the size of the queue. Install the SQLite command-line tool (winget install --id SQLite.SQLite --exact --source winget), keep the app closed, and run this read-only check in PowerShell:
    sqlite3 -readonly "$env:USERPROFILE\.codex\.codex-global-state.sqlite" "SELECT round(length(CAST(value AS BLOB))/1048576.0, 1) AS queue_MiB FROM settings WHERE scope='global' AND key='queued-follow-ups';"
    It prints only a size in MiB, not your chats. If you set CODEX_HOME, use that folder instead of %USERPROFILE%\.codex. Users who had this error saw values from about 257 to 466 MiB.
  4. Back up the file (app still closed), with a plain copy in PowerShell:
    Copy-Item "$env:USERPROFILE\.codex\.codex-global-state.sqlite" "$env:USERPROFILE\.codex\global-state-backup.sqlite"
  5. Empty the queue, following the users' own steps. Users who couldn't open the chat emptied the queued-follow-ups entry in that file and the app came back. Their exact commands are in openai/codex #64073 and #63610; follow them only with the backup above in place. We haven't tested these commands, so we don't repeat them here. Emptying the queue throws away every unsent queued message, in all chats, including any text in them. Users report that chat history and project files stay.
  6. Open the app and send a short text message to test it. Don't resend the same batch of images. Send fewer, smaller ones.

Why it happens

Users who read the app's logs found the same pattern. When you send images, the desktop app saves the message in a local queue first. A very large message (many full-size screenshots or photos) can grow past Electron's 512 MiB message limit (536,870,912 bytes). The app then logs:

Failed to execute queued message: RangeError: Message exceeds the 536870912-byte serialization limit.
Peer closed MessagePort connection

Because the message stays in the queue, the app tries it again on every launch and every send. That is why repair, reset, reinstall and restarting Windows don't help: the queue lives in your .codex folder, not in the app's install folder.

How to check it's this problem

  • It started right after you attached, pasted or dropped images (or videos in Work).
  • It now happens even on short text messages, and often in new chats too.
  • The read-only check above prints a large number (hundreds of MiB).

If the queue is small, you may have a different bug with the same dialog. Some users got it on the second message of any chat with no images at all (#62901). For them, a second Windows user profile worked, and rolling back the app helped only for a while.

What didn't help in reports

  • Windows Settings > Apps > Repair or Reset, reinstalling, or resetting the Microsoft Store.
  • Restarting Windows.
  • Updating to 26.1120.6357.0 (users still hit it there).

Running Claude Code, Codex or Cursor on real repos, or shipping an AI agent? A Quick Review ($149 / ₹13,900, 1 working day) checks one repo, config or setup for leaked keys, risky agent permissions and MCP servers. Request a Quick Review

FAQ

What causes 'Peer closed MessagePort connection' in Codex?

In user reports it follows an unsent message with many or large images. It stays in the desktop app's local queue and goes over Electron's 512 MiB message limit, so every send fails. OpenAI hasn't confirmed the cause.

Will clearing queued-follow-ups delete my chats?

No, according to the users who did it. It removes unsent queued messages only, including any text in them. Chat history and project files stay. Back up the file first anyway.

Why doesn't reinstalling fix it?

The stuck message is stored in .codex-global-state.sqlite in your .codex folder, which a reinstall or app reset doesn't remove.

Where is .codex-global-state.sqlite on Windows?

In %USERPROFILE%\.codex\ by default, or in the folder set by CODEX_HOME.

Is there an official fix?

Not as of 4 Dec 2026. No OpenAI reply on the GitHub issues. Users have asked for a size limit on attachments and a way to cancel a stuck queued message in the app.

Related errors

Sources

Read 4 Dec 2026. These tools change often: if a step no longer matches, the linked page wins.

Related free tools