Codex Switch Account: 2 Commands, or Many Accounts
Short answer: to do a Codex switch account in the CLI, run codex logout, then codex login and sign in with the other ChatGPT account in the browser; codex login status confirms it. To keep several accounts signed in, give each its own CODEX_HOME directory. Then restart open Codex sessions, because a running session keeps the account it started with.
Checked 14 November 2026 against OpenAI’s Codex authentication docs and the Codex CLI 0.169.0 source.
TL;DR
- Quick switch, built in:
codex logoutthencodex login. One browser sign-in per switch. - Many accounts at once: one
CODEX_HOMEper account plus a shell alias each. - Where the login lives:
$CODEX_HOME/auth.json(default~/.codex/auth.json), unless you moved it to the OS keyring. - Open sessions need a restart after any switch:
/quit, then startcodexagain. - One-click switch from the menu bar: FavTray Pro or CodexBar (free, open source).
- Switching never adds usage. Each account keeps its own limits.
Codex switch account: how do you switch accounts in the Codex CLI?
You switch accounts in the Codex CLI by logging out and logging back in with the other ChatGPT account. Codex caches one login per CODEX_HOME, so the new sign-in replaces the old one.
codex logout # clears the cached login
codex login # opens the browser: sign in with the other account
codex login status # read-only: shows how you're signed in
The commands are the same ones OpenAI documents on its authentication page. In the browser, pick the right ChatGPT account (and workspace, if you belong to a Team or Enterprise one) before you approve.
This is the right method for an occasional change. The catch: switching back costs another browser sign-in, every time.
Can you switch Codex accounts without leaving a session?
Partly. Inside an open Codex session, /logout logs you out (it’s in the 0.169.0 slash-command list as “log out of Codex”). There’s no /login command, so you still finish with codex login in a terminal and start a new session.
How do you log in to the Codex CLI?
Run codex login and finish the sign-in in the browser that opens. That’s the default ChatGPT sign-in, and it uses your ChatGPT plan’s Codex limits. OpenAI documents three other ways:
| Method | Command | Use it when |
|---|---|---|
| ChatGPT, browser | codex login | You’re on a Mac with a browser |
| ChatGPT, device code | codex login --device-auth | SSH session, headless box, or the browser flow fails |
| API key | printenv OPENAI_API_KEY | codex login --with-api-key | You want pay-as-you-go API billing instead of plan limits |
| Access token | printenv CODEX_ACCESS_TOKEN | codex login --with-access-token | Automation, per OpenAI’s auth docs |
--device-auth prints a code you enter on another device, so it’s also the fix when codex login can’t open a browser on the machine you’re on.
Admins can lock this down: forced_login_method ("chatgpt" or "api") and forced_chatgpt_workspace_id in config.toml restrict which login and workspace Codex accepts. According to the docs, if your credentials don’t match, “Codex logs the user out and exits.” If a switch keeps logging you straight out, check for those keys.
How do you log out of the Codex CLI?
Run codex logout in Terminal, or type /logout inside a running session. Both clear the stored credentials.
Two things to know:
- The IDE extension shares the login. OpenAI’s docs say “The CLI and extension share the same cached login details,” so logging out of one signs out the other.
- Exiting is not logging out.
/quitor/exitcloses a session and keeps you signed in. If you searched “how to exit Codex”, that’s the one you want.
Where does the Codex CLI store your login?
Codex stores its login in auth.json under CODEX_HOME, which defaults to ~/.codex. The cli_auth_credentials_store setting in config.toml can move it:
cli_auth_credentials_store | Where the login goes |
|---|---|
file | $CODEX_HOME/auth.json |
keyring | The OS credential store (fails if it’s unavailable) |
auto | The OS store when available, otherwise auth.json |
ephemeral | Memory only, for the current process |
A ChatGPT sign-in writes auth.json with a tokens block (ID, access and refresh tokens plus the ChatGPT account_id) and a last_refresh time. The docs’ warning applies: “treat ~/.codex/auth.json like a password: it contains access tokens.” Don’t commit it, paste it into a ticket or share it in chat.
How do you use multiple Codex accounts at the same time?
Give each account its own CODEX_HOME directory and sign in once in each. Codex reads its login from whichever directory the variable points at, so two accounts can be signed in on one Mac.
CODEX_HOME=~/.codex-work codex login
CODEX_HOME=~/.codex-client codex login
Then add aliases to ~/.zshrc:
alias codex-work='CODEX_HOME=~/.codex-work codex'
alias codex-client='CODEX_HOME=~/.codex-client codex'
Plain codex keeps using ~/.codex, and each alias starts Codex on its own account. Two terminals can run two accounts side by side.
Trade-offs:
- Everything in
CODEX_HOMEis per account, not only the login:config.toml, history and sessions too. Copy or symlinkconfig.tomlif you want the same settings everywhere. - The IDE extension and other apps use
~/.codexunless they’re launched with the variable set. - You choose at launch. A running session can’t change account.
Does switching accounts change which sessions you can resume?
It can. Codex 0.168.0’s release notes say the local history and resume pickers “filter newly created threads by the signed-in ChatGPT account”. So after a switch, /resume may not list a chat you started on the other account. Switch back to see it. With separate CODEX_HOME directories, each account’s sessions live in its own folder anyway.
Why not just copy auth.json between accounts?
Copying saved auth.json files over each other works for a while, then breaks on token refresh. Codex refreshes a ChatGPT login automatically: in the 0.169.0 source it refreshes when the access token is within 5 minutes of expiry, or 8 days after last_refresh, and a refresh replaces the refresh token. A copy you saved last week may then fail with refresh_token_reused, refresh_token_expired or refresh_token_invalidated, and Codex tells you to log out and sign in again.
Two rules keep a hand-rolled switcher working:
- Save a fresh copy of the outgoing account’s
auth.jsonright before each swap. - Write the new file atomically: a temp file with mode 0600, then rename it over
auth.json, so Codex never reads half a file.
Why do open Codex sessions need a restart after switching?
A running Codex session loads its credentials at startup and keeps them in memory. In the 0.169.0 source it reloads auth.json only when the file still holds the same account id (that’s how it picks up its own refreshed tokens), and logs “Skipping auth reload due to account id mismatch” otherwise.
So after any switch, by hand or with an app:
- Type
/quitin each opencodexsession and start it again. - Reload the IDE extension if you use it.
OpenAI doesn’t document this behaviour. It’s what the current source does and it may change.
Claude Code behaves differently: in our tests, open sessions followed a switch within about 30 seconds. See how to switch Claude Code accounts on Mac.
Is there a Codex account switcher app for Mac?
Yes. OpenAI doesn’t ship a switcher, but menu bar apps can save each ChatGPT login and swap it in for you. Two that do this as of November 2026:
| App | Price | Codex account switching | Also shows |
|---|---|---|---|
| CodexBar | Free, open source (MIT) | Managed Codex accounts you can name; 0.84.0 (7 Nov 2026) keeps saved accounts apart even with the same email | Usage for Codex, Claude and other providers |
| FavTray Pro | $4.99 once (Lifetime) | Save, add and switch ChatGPT logins from the account chip on the Codex card | Codex and Claude limits, plus the rest of FavTray’s tools |
FavTray is a macOS menu bar app of developer and productivity tools, free with daily limits on a few of them, and $4.99 once for Lifetime. We make it, so weigh our take accordingly. If all you want is free Codex switching, CodexBar does it well.
How do you switch Codex accounts in FavTray?
- Save current login: click the account chip on the Codex card in AI Usage and save the account you’re signed in with.
- Add account…: FavTray runs
codex loginwith a temporaryCODEX_HOME, so your current login isn’t touched. Sign in with the other account in the browser and FavTray saves it. - Switch: click the chip and pick an account. The toast reminds you to restart open Codex sessions.
How it works:
- Fresh copy first. Before a swap, FavTray saves the current
auth.jsonfor the outgoing account, then writes the new one as a 0600 temp file and renames it into place. It reads the file back and restores the old one if anything’s off. - Saved logins stay on your Mac, in FavTray’s own Keychain items.
- Last-known limits, no renewing. The menu shows each inactive account’s limits as of when you last used it. FavTray never signs in or renews a login itself; Codex renews it when it next runs. An account unused for a long time may need one more
codex login, and FavTray marks it Sign in again only when OpenAI has actually rejected the login. - A nudge, not an autopilot. Near 90% of the active account’s 5-hour or weekly limit, a notification suggests the saved account with the most room. It never switches for you.
Limits: it switches ChatGPT sign-ins, not API-key logins, and not the keyring store. Account switching is part of Pro (the 7-day trial includes it); the Codex usage bars stay free. See pricing. For a wider comparison of switchers, read multiple Claude Code accounts: the best tools.
Does switching Codex accounts increase your usage limits?
No. Every ChatGPT account has its own plan and its own Codex limits, and nothing is pooled. Switching moves you between accounts you own, such as personal and work, and each one stays under OpenAI’s terms. To see how much is left on the active account, run /status in Codex or read how to check Codex usage limits on Mac.
Which Codex account method should you use?
| You want to… | Use | Setup | Sign-ins per switch |
|---|---|---|---|
| Change account now and then | codex logout + codex login | None | 1 browser sign-in |
| Run two accounts side by side, or isolate clients | One CODEX_HOME per account | 1 alias per account | 0 (pick at launch) |
| Switch your default login from the menu bar and see each account’s last-known limits | CodexBar or FavTray Pro | Save each account once | 0 |
For how the two agents compare, see OpenAI Codex vs Claude Code, and for every usage tracker side by side, the best AI usage tracking tools.
Sources (checked 14 November 2026): Codex authentication, Codex releases and the Codex CLI 0.169.0 source (codex-rs/login, codex-rs/tui), CodexBar releases. Refresh and session behaviour come from the source, not the docs, and may change.
Frequently Asked Questions
How do I switch accounts in the Codex CLI?
Run codex logout in Terminal, then codex login and sign in with the other ChatGPT account in the browser. Run codex login status to confirm which method is active. Inside a running session you can type /logout instead. To keep several accounts signed in at once, give each its own CODEX_HOME directory or save each login in a menu bar switcher.
How do I log out of the Codex CLI?
Run codex logout in Terminal, or type /logout inside an open Codex session. Both clear the stored login in ~/.codex/auth.json (or the OS keyring if you use it). The CLI and the IDE extension share that login, so logging out of one signs you out of the other. Run codex login to sign in again.
Where does Codex store its login?
In auth.json inside CODEX_HOME, which is ~/.codex by default. If config.toml sets cli_auth_credentials_store to keyring, Codex uses the operating system's credential store instead, and auto uses the keyring when it is available. OpenAI says to treat auth.json like a password because it contains access tokens, so never commit or share it.
Can I use multiple Codex accounts at the same time?
Yes, with one CODEX_HOME directory per account. Sign in once in each, for example CODEX_HOME=~/.codex-work codex login, then start Codex with the same variable through an alias such as codex-work. Two terminals can then run two accounts side by side. Each directory also holds its own config.toml, history and sessions.
Why doesn't my open Codex session use the new account?
A running Codex session loads its login at startup and keeps it in memory. In the current source it only reloads auth.json when the file still holds the same account, so a different account is ignored until you restart. After switching, quit open sessions with /quit and start them again, and reload the IDE extension.
Does switching Codex accounts give me more usage?
No. Each ChatGPT account has its own plan and its own Codex limits, and nothing is pooled between them. Switching is for moving between accounts you own, such as personal and work, and every account stays under OpenAI's terms. To see what is left on the active account, run /status in Codex or check the usage dashboard.