Logging out of the Codex CLI clears cached sign-in details from the local machine, which helps reduce accidental access from shared terminals and workstations. It is also useful when switching accounts or completing a credential rotation.

The CLI and IDE extension share cached credentials stored in the OS credential store or /~/.codex/auth.json for file-based storage. Running codex logout removes the cached session so subsequent commands return to an unauthenticated state.

Logging out only affects the local machine state and does not revoke server-side credentials such as API keys or previously issued tokens. If compromise is suspected, revoke or rotate credentials at the source and confirm the CLI shows an unauthenticated status after logout.

Steps to log out of Codex:

  1. Exit any active interactive session before logging out.
    /exit
  2. Remove stored authentication credentials.
    $ codex logout
    Successfully logged out

    Repeat in each user account that previously authenticated on the same machine.

  3. Confirm the CLI is no longer authenticated.
    $ codex login status
    Not logged in
  4. Run a simple command to confirm the CLI requires a fresh login.
    $ codex exec --skip-git-repo-check "Return OK."
    ERROR: unexpected status 401 Unauthorized: