openai/codex · error · TransportClosedError

Codex process is not running

Error message

Codex process is not running

What it means

Error "Codex process is not running" thrown in openai/codex.

Source

Thrown at sdk/python/src/openai_codex/client.py:838

        except BaseException as exc:
            self._router.fail_all(exc)

    def _stderr_tail(self, limit: int = 40) -> str:
        return "\n".join(list(self._stderr_lines)[-limit:])

    def _handle_server_request(self, msg: dict[str, JsonValue]) -> JsonObject:
        method = msg["method"]
        params = msg.get("params")
        if not isinstance(method, str):
            return {}
        return self._approval_handler(
            method,
            params if isinstance(params, dict) else None,
        )

    def _write_message(self, payload: JsonObject) -> None:
        if self._proc is None or self._proc.stdin is None:
            raise TransportClosedError("Codex process is not running")
        with self._lock:
            self._proc.stdin.write(json.dumps(payload) + "\n")
            self._proc.stdin.flush()

    def _read_message(self) -> dict[str, JsonValue]:
        if self._proc is None or self._proc.stdout is None:
            raise TransportClosedError("Codex process is not running")

        line = self._proc.stdout.readline()
        if not line:
            raise TransportClosedError(
                f"Codex process closed stdout. stderr_tail={self._stderr_tail()[:2000]}"
            )

        try:
            message = json.loads(line)
        except json.JSONDecodeError as exc:
            raise CodexError(f"Invalid JSON-RPC line: {line!r}") from exc

View on GitHub (pinned to 339751715c)

Solutions

  1. Start the client before sending requests; if it crashed, inspect stderr output and relaunch.

When it happens

Trigger: Thrown at sdk/python/src/openai_codex/client.py:838 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/4823db11ab0bbc84. Report an issue: GitHub.