openai/codex · error · anyhow::Error

app server is running but is not managed by codex…

Error message

app server is running but is not managed by codex app-server daemon

What it means

During restart, the daemon probed the socket and found a live app-server, but the recorded backend state shows it was not started by this daemon (no matching managed pid backend), so the daemon refuses to restart a process it does not own.

Solutions

  1. Stop the externally started app-server (e.g. `pkill` the codex app-server process) so the daemon can start its own managed backend
  2. Re-run `codex app-server-daemon start` after the unmanaged server is gone
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at codex-rs/app-server-daemon/src/lib.rs:340 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/cb4a2bf38bfb2a5b. Report an issue: GitHub.

Appendix: source

Thrown at codex-rs/app-server-daemon/src/lib.rs:340

        self.ensure_managed_codex_bin()?;
        let pid = self.start_managed_backend(&settings).await?;
        let info = self.wait_until_ready().await?;
        Ok(self
            .output(
                LifecycleStatus::Started,
                Some(BackendKind::Pid),
                pid,
                Some(info.app_server_version),
            )
            .await)
    }

    async fn restart(&self) -> Result<LifecycleOutput> {
        let settings = self.load_settings().await?;
        if client::probe(&self.socket_path).await.is_ok()
            && self.running_backend(&settings).await?.is_none()
        {
            return Err(anyhow!(
                "app server is running but is not managed by codex app-server daemon"
            ));
        }

        self.ensure_managed_codex_bin()?;
        if let Some(backend) = self.running_backend_instance(&settings).await? {
            backend.stop().await?;
        }

        let pid = self.start_managed_backend(&settings).await?;
        let info = self.wait_until_ready().await?;
        Ok(self
            .output(
                LifecycleStatus::Restarted,
                Some(BackendKind::Pid),
                pid,
                Some(info.app_server_version),
            )

View on GitHub (pinned to 339751715c)