Skip to content
2api2api Docs
Open console

FAQ

Codex install and sign-in

Command not found, scripts disabled, stuck sign-in, Token exchange failed, region messages, unavailable models. Find your case by the error message.

Run codex doctor first. It checks the install, config, sign-in, Git and terminal, and produces a diagnostic report. For many problems, the report tells you what’s wrong.

For errors related to the 2api setup (401, stream disconnected, repeated Reconnecting and so on), see the Codex FAQ.

On Windows it reads 'codex' is not recognized as an internal or external command, or The term 'codex' is not recognized as the name of a cmdlet, function, script file, or operable program. On a Chinese-language system, these read 'codex' 不是内部或外部命令 and 无法将“codex”项识别为 cmdlet、函数、脚本文件或可运行程序的名称.

  • After installing, open a new terminal. Terminals that were open before the install don’t pick up the new PATH.
  • Make sure it really got installed: run the install command again and check for errors.
  • If you installed with npm, run npm prefix -g to find npm’s global directory. On macOS / Linux, add the bin folder inside it to PATH. On Windows, add the directory itself to PATH.

The full error is irm : The term 'irm' is not recognized, or 'irm' is not recognized as an internal or external command. On a Chinese-language system it reads 无法将“irm”项识别为 cmdlet.

You ran the PowerShell install command in CMD (Command Prompt). Open PowerShell and run it there.

running scripts is disabled on this system

Section titled “running scripts is disabled on this system”

The full error is codex.ps1 cannot be loaded because running scripts is disabled on this system. It may name npm.ps1 instead. On a Chinese-language system it reads 因为在此系统上禁止运行脚本.

By default, PowerShell doesn’t allow scripts to run. Run the command below, or use codex.cmd instead of codex. For details, see Windows tips.

Terminal window
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

During a global npm install, you don’t have permission to write to system directories. Don’t add sudo. Use the official install script instead, or install Node.js with nvm first and then install Codex.

Missing optional dependency @openai/codex-win32-x64

Section titled “Missing optional dependency @openai/codex-win32-x64”

npm didn’t install the Windows program files. Uninstall and reinstall:

Terminal window
npm uninstall -g @openai/codex
npm install -g @openai/codex

If that doesn’t help, use the official PowerShell install script instead. See Install Codex.

Since July 2026, the Codex desktop app has been part of the ChatGPT desktop app. Open the new ChatGPT and choose Codex from the dropdown menu in the top-left corner. ChatGPT Classic is the old version and doesn’t have Codex.

  • Press Win+R and run wsreset to clear the Store cache, then try again.
  • Or install it with a command: winget install --id 9PLM9XGG6VKS -s msstore.
  • Don’t download installers from third-party sites.

The browser says you’re signed in, but the terminal keeps waiting

Section titled “The browser says you’re signed in, but the terminal keeps waiting”

The browser may also show localhost refused to connect (on a Chinese-language system, localhost 拒绝了我们的连接请求).

The browser has to hand the sign-in result back to localhost:1455 on your computer, and a proxy or port problem is blocking that step. Go through the steps in Sign in to Codex in order. If nothing works, sign in with a device code: codex login --device-auth.

It may also show token_exchange_failed.

The sign-in in the browser worked, but when Codex tried to exchange the result for credentials, it couldn’t reach OpenAI’s authentication service.

  • If your computer reaches the internet through an HTTP proxy, set HTTPS_PROXY in the same terminal where you run codex login, and also set NO_PROXY=localhost,127.0.0.1.
  • If your company network has a TLS proxy, set CODEX_CA_CERTIFICATE. See Corporate networks and sign-in logs.
  • Check codex-login.log in ~/.codex/log. It shows the specific cause.
  • Make sure you’re using the right account and sign-in method.
  • Clear the cookies for chatgpt.com and openai.com in your browser, or try again in another browser or a private window.
  • Sign in with a device code instead: codex login --device-auth.
  • If it still fails, send codex-login.log to support.

Country, region, or territory not supported

Section titled “Country, region, or territory not supported”

This is OpenAI’s regional restriction: OpenAI has determined that your current network location is outside the regions it supports. There’s nothing wrong with your account or subscription. OpenAI only provides its service in the countries and territories it supports (list). According to OpenAI, using it in other regions may get your account restricted.

First turn on device code sign-in in the security settings of ChatGPT on the web, then run codex login --device-auth. For a workspace account, ask your admin to turn it on in the workspace permissions.

Signed out right after signing in, or refresh token was already used

Section titled “Signed out right after signing in, or refresh token was already used”
Terminal window
codex logout
codex login

If it keeps happening, first update Codex to the latest version. If that doesn’t help, back up and delete ~/.codex/auth.json, then sign in again. Don’t delete ~/.codex/sessions. That’s where your session history is.

is not supported when using Codex with a ChatGPT account

Section titled “is not supported when using Codex with a ChatGPT account”

This model isn’t available on your plan, or it has been retired. In Codex signed in with ChatGPT, GPT-5.4 and GPT-5.4 mini were retired on August 31, 2026, and GPT-5.5 on October 14. Use /model to switch to a model that’s in the list.

Free and Go can only use GPT-6 Luna in the desktop app. To use Codex in the CLI or the IDE extension, you need Plus or a higher plan.

Startup error after upgrading, with approval_policy = "untrusted" in the config

Section titled “Startup error after upgrading, with approval_policy = "untrusted" in the config”

The value untrusted is deprecated and may stop Codex from starting. In ~/.codex/config.toml, change this line to approval_policy = "on-request", or just delete it.

--full-auto has been removed. To let codex exec change files, use --sandbox workspace-write instead.

  • Make sure you installed the extension whose publisher is OpenAI and whose ID is openai.chatgpt.
  • Press Ctrl+Shift+P (Cmd+Shift+P on macOS) and run Codex: Open Codex Sidebar.
  • In Cursor, the icon may be hidden under More in the activity bar. Drag it out and pin it.

The IDE extension is stuck signing in or keeps spinning

Section titled “The IDE extension is stuck signing in or keeps spinning”
  • First sign in with codex login in a terminal. The extension and the CLI share sign-in information.
  • If that doesn’t help, fully quit the editor, back up and delete ~/.codex/auth.json, then sign in again.
  • If nothing happens at all on Windows, you may be missing C++ components. See Install Codex.

Windows policy doesn’t allow Codex’s sandbox user to start commands. See Windows tips.