API access (401) and "no_matching_rule" error

Resolved 💬 8 comments Opened Jun 22, 2026 by adulau Closed Jun 25, 2026
💡 Likely answer: A maintainer (efrazer-oai, contributor) responded on this thread — see the highlighted reply below.

What version of Codex CLI is running?

codex-cli 0.141.0

What subscription do you have?

Business

Which model were you using?

gpt-5.5

What platform is your computer?

_No response_

What terminal emulator and version are you using (if applicable)?

Linux 6.8.0-124-generic x86_64 x86_64

Codex doctor report

{
  "schemaVersion": 1,
  "generatedAt": "1782110794s since unix epoch",
  "overallStatus": "warning",
  "codexVersion": "0.141.0",
  "checks": {
    "app_server.status": {
      "id": "app_server.status",
      "category": "app-server",
      "status": "ok",
      "summary": "background server is not running",
      "details": {
        "control socket": "/home/adulau/.codex/app-server-control/app-server-control.sock",
        "daemon state dir": "/home/adulau/.codex/app-server-daemon",
        "mode": "ephemeral",
        "pid file": "/home/adulau/.codex/app-server-daemon/app-server.pid (missing)",
        "settings": "/home/adulau/.codex/app-server-daemon/settings.json (missing)",
        "status": "not running",
        "update-loop pid file": "/home/adulau/.codex/app-server-daemon/app-server-updater.pid (missing)"
      },
      "remediation": null,
      "durationMs": 0
    },
    "auth.credentials": {
      "id": "auth.credentials",
      "category": "auth",
      "status": "ok",
      "summary": "auth is configured",
      "details": {
        "auth file": "/home/adulau/.codex/auth.json",
        "auth storage mode": "File",
        "stored API key": "true",
        "stored ChatGPT tokens": "false",
        "stored agent identity": "false",
        "stored auth mode": "api_key"
      },
      "remediation": null,
      "durationMs": 0
    },
    "config.load": {
      "id": "config.load",
      "category": "config",
      "status": "ok",
      "summary": "config loaded",
      "details": {
        "CODEX_HOME": "/home/adulau/.codex",
        "config.toml": "/home/adulau/.codex/config.toml",
        "config.toml parse": "ok",
        "cwd": "/home/adulau/git/fanything",
        "enabled feature flags": "shell_tool, unified_exec, shell_snapshot, terminal_resize_reflow, sqlite, hooks, enable_request_compression, multi_agent, apps, tool_suggest, plugins, in_app_browser, browser_use, browser_use_external, computer_use, plugin_sharing, image_generation, skill_mcp_dependency_install, mentions_v2, steer, guardian_approval, goals, collaboration_modes, tool_call_mcp_elicitation, personality, fast_mode, tui_app_server, remote_compaction_v2, workspace_dependencies",
        "feature flag overrides": "none",
        "feature flags enabled": "29",
        "log dir": "/home/adulau/.codex/log",
        "mcp servers": "0",
        "model": "gpt-5.5",
        "model provider": "openai",
        "sqlite home": "/home/adulau/.codex"
      },
      "remediation": null,
      "durationMs": 0
    },
    "git.environment": {
      "id": "git.environment",
      "category": "git",
      "status": "ok",
      "summary": "git version 2.34.1",
      "details": {
        ".git entry": "directory",
        "PATH git #1": "/usr/bin/git",
        "PATH git #2": "/bin/git",
        "PATH git entries": "2",
        "git branch": "main",
        "git build options": "git version 2.34.1; cpu: x86_64; no commit associated with this build; sizeof-long: 8; sizeof-size_t: 8; shell-path: /bin/sh",
        "git exec path": "/usr/lib/git-core",
        "git version": "git version 2.34.1",
        "repo detected": "true",
        "repo root": "/home/adulau/git/fanything",
        "selected git": "/usr/bin/git"
      },
      "remediation": null,
      "durationMs": 146
    },
    "installation": {
      "id": "installation",
      "category": "install",
      "status": "ok",
      "summary": "installation looks consistent",
      "details": {
        "PATH codex #1": "/home/adulau/.local/bin/codex",
        "PATH codex #2": "/home/adulau/.local/bin//codex",
        "PATH codex #3": "/home/adulau/.local/bin/codex",
        "PATH codex #4": "/home/adulau/.local/bin//codex",
        "PATH codex #5": "/home/adulau/.local/bin/codex",
        "PATH codex entries": "5",
        "current executable": "/home/adulau/.codex/packages/standalone/releases/0.141.0-x86_64-unknown-linux-musl/bin/codex",
        "install context": "standalone (unix, package /home/adulau/.codex/packages/standalone/releases/0.141.0-x86_64-unknown-linux-musl, bin /home/adulau/.codex/packages/standalone/releases/0.141.0-x86_64-unknown-linux-musl/bin, resources /home/adulau/.codex/packages/standalone/releases/0.141.0-x86_64-unknown-linux-musl/codex-resources, path /home/adulau/.codex/packages/standalone/releases/0.141.0-x86_64-unknown-linux-musl/codex-path)",
        "managed by bun": "false",
        "managed by npm": "false",
        "managed package root": "not set"
      },
      "remediation": null,
      "durationMs": 1
    },
    "mcp.config": {
      "id": "mcp.config",
      "category": "mcp",
      "status": "ok",
      "summary": "no MCP servers configured",
      "details": {},
      "remediation": null,
      "durationMs": 0
    },
    "network.env": {
      "id": "network.env",
      "category": "network",
      "status": "ok",
      "summary": "network-related environment looks readable",
      "details": {
        "proxy env vars": "none"
      },
      "remediation": null,
      "durationMs": 0
    },
    "network.provider_reachability": {
      "id": "network.provider_reachability",
      "category": "reachability",
      "status": "ok",
      "summary": "active provider endpoints are reachable over HTTP",
      "details": {
        "openai API base URL": "https://api.openai.com/v1 reachable (HTTP 404)",
        "openai API route probe": "https://api.openai.com/v1/<redacted> route exists (HTTP 401)",
        "reachability mode": "API key auth"
      },
      "remediation": null,
      "durationMs": 846
    },
    "network.websocket_reachability": {
      "id": "network.websocket_reachability",
      "category": "websocket",
      "status": "warning",
      "summary": "Responses WebSocket failed; HTTPS fallback may still work",
      "details": {
        "DNS": "2 IPv4, 0 IPv6, first IPv4",
        "auth mode": "api_key",
        "connect timeout": "15000 ms",
        "endpoint": "wss://api.openai.com/v1/<redacted>",
        "handshake transport error": "http 401 Unauthorized: Some(\"{\\n  \\\"error\\\": {\\n    \\\"message\\\": \\\"Unauthorized\\\",\\n    \\\"type\\\": \\\"rejected_by_access_enforcement\\\",\\n    \\\"code\\\": \\\"no_matching_rule\\\",\\n    \\\"param\\\": null\\n  },\\n  \\\"status\\\": 401\\n}\")",
        "model provider": "openai",
        "provider name": "OpenAI",
        "proxy env vars": "none",
        "supports websockets": "true",
        "wire API": "responses"
      },
      "remediation": "Check proxy, VPN, firewall, DNS, custom CA, and WebSocket policy support.",
      "durationMs": 717
    },
    "runtime.provenance": {
      "id": "runtime.provenance",
      "category": "runtime",
      "status": "ok",
      "summary": "running standalone on linux-x86_64",
      "details": {
        "commit": "unknown",
        "current executable": "/home/adulau/.codex/packages/standalone/releases/0.141.0-x86_64-unknown-linux-musl/bin/codex",
        "install method": "standalone (unix, package /home/adulau/.codex/packages/standalone/releases/0.141.0-x86_64-unknown-linux-musl, bin /home/adulau/.codex/packages/standalone/releases/0.141.0-x86_64-unknown-linux-musl/bin, resources /home/adulau/.codex/packages/standalone/releases/0.141.0-x86_64-unknown-linux-musl/codex-resources, path /home/adulau/.codex/packages/standalone/releases/0.141.0-x86_64-unknown-linux-musl/codex-path)",
        "platform": "linux-x86_64",
        "version": "0.141.0"
      },
      "remediation": null,
      "durationMs": 0
    },
    "runtime.search": {
      "id": "runtime.search",
      "category": "search",
      "status": "ok",
      "summary": "search is OK (bundled)",
      "details": {
        "search command": "/home/adulau/.codex/packages/standalone/releases/0.141.0-x86_64-unknown-linux-musl/codex-path/rg",
        "search command readiness": "file exists",
        "search provider": "bundled"
      },
      "remediation": null,
      "durationMs": 0
    },
    "sandbox.helpers": {
      "id": "sandbox.helpers",
      "category": "sandbox",
      "status": "ok",
      "summary": "sandbox configuration is readable",
      "details": {
        "approval policy": "OnRequest",
        "codex-linux-sandbox helper": "/home/adulau/.codex/tmp/arg0/codex-arg0FWopOO/codex-linux-sandbox",
        "execve wrapper helper": "/home/adulau/.codex/tmp/arg0/codex-arg0FWopOO/codex-execve-wrapper",
        "filesystem sandbox": "restricted",
        "network sandbox": "restricted"
      },
      "remediation": null,
      "durationMs": 0
    },
    "state.paths": {
      "id": "state.paths",
      "category": "state",
      "status": "ok",
      "summary": "state paths and databases are inspectable",
      "details": {
        "CODEX_HOME": "/home/adulau/.codex (dir)",
        "active rollout files": "9 files, 359180 total bytes, 39908 average bytes",
        "archived rollout files": "0 files, 0 total bytes, 0 average bytes",
        "goals DB": "/home/adulau/.codex/goals_1.sqlite (file)",
        "goals DB integrity": "ok",
        "log DB": "/home/adulau/.codex/logs_2.sqlite (file)",
        "log DB integrity": "ok",
        "log dir": "/home/adulau/.codex/log (missing)",
        "memories DB": "/home/adulau/.codex/memories_1.sqlite (file)",
        "memories DB integrity": "ok",
        "sqlite home": "/home/adulau/.codex (dir)",
        "standalone release cache": "1 entries in /home/adulau/.codex/packages/standalone/releases",
        "state DB": "/home/adulau/.codex/state_5.sqlite (file)",
        "state DB integrity": "ok"
      },
      "remediation": null,
      "durationMs": 183
    },
    "state.rollout_db_parity": {
      "id": "state.rollout_db_parity",
      "category": "threads",
      "status": "ok",
      "summary": "rollout files and state DB thread inventory agree",
      "details": {
        "default model provider": "openai",
        "rollout DB active files": "9",
        "rollout DB active rows": "9",
        "rollout DB archive mismatches": "0",
        "rollout DB archived files": "0",
        "rollout DB archived rows": "0",
        "rollout DB duplicate DB paths": "0",
        "rollout DB duplicate rollout thread ids": "0",
        "rollout DB malformed file names": "0",
        "rollout DB missing active rows": "0",
        "rollout DB missing archived rows": "0",
        "rollout DB model providers": "openai=9",
        "rollout DB rows": "9",
        "rollout DB scan cap reached": "false",
        "rollout DB scan errors": "0",
        "rollout DB sources": "cli=9",
        "rollout DB stale rows": "0"
      },
      "remediation": null,
      "durationMs": 164
    },
    "system.environment": {
      "id": "system.environment",
      "category": "system",
      "status": "ok",
      "summary": "OS language en-US",
      "details": {
        "EDITOR": "not set",
        "LANG": "en_US.UTF-8",
        "VISUAL": "not set",
        "os": "Ubuntu 22.4.0 (jammy) [64-bit]",
        "os language": "en-US",
        "os type": "Ubuntu",
        "os version": "22.4.0"
      },
      "remediation": null,
      "durationMs": 85
    },
    "terminal.env": {
      "id": "terminal.env",
      "category": "terminal",
      "status": "ok",
      "summary": "terminal metadata was detected",
      "details": {
        "COLORTERM": "truecolor",
        "DISPLAY": "present",
        "color output": "enabled",
        "effective locale": "en_US.UTF-8",
        "stderr is terminal": "true",
        "stdin is terminal": "true",
        "stdout is terminal": "true",
        "terminal": "GNOME Terminal",
        "terminal size": "425x82"
      },
      "remediation": null,
      "durationMs": 0
    },
    "terminal.title": {
      "id": "terminal.title",
      "category": "title",
      "status": "ok",
      "summary": "terminal title default",
      "details": {
        "terminal title activity": "true",
        "terminal title items": "activity, project-name",
        "terminal title project source": "git repo root",
        "terminal title project value": "fanything",
        "terminal title source": "default"
      },
      "remediation": null,
      "durationMs": 0
    },
    "updates.status": {
      "id": "updates.status",
      "category": "updates",
      "status": "ok",
      "summary": "update configuration is locally consistent",
      "details": {
        "cached latest version": "0.141.0",
        "check for update on startup": "true",
        "last checked at": "2026-06-22T06:29:01.241746487Z",
        "latest version": "0.141.0",
        "latest version status": "current version is not older",
        "update action": "standalone installer",
        "version cache": "/home/adulau/.codex/version.json"
      },
      "remediation": null,
      "durationMs": 129
    }
  }
}

What issue are you seeing?

API access/Login failed with a business using a personal access token with no_matching_rule.

What steps can reproduce the bug?

run codex and try to run any command

What is the expected behavior?

Being able to login

Additional information

_No response_

View original on GitHub ↗

8 Comments

0xv3 · 26 days ago

Same symptom on a Business-plan account (gpt-5.5). On the same account and endpoint, an OAuth login works, but an opaque PAT (at-…) returns 401 with body type: rejected_by_access_enforcement, code: no_matching_rule. Adding the official CLI's headers and originator to the PAT request doesn't change it. This PAT worked until a few days ago ago, so it appears to be a recent change. Is PAT-based Codex access intentionally being restricted in favor of OAuth, or is this a regression? codex doctor's network remediation is misleading here.

Corei13 · 26 days ago

same here, worked until yesterday and started happening today

cdirks4 · 26 days ago

Same rejected_by_access_enforcement / no_matching_rule on a Business-plan account (codex-cli 0.142.0, gpt-5.5) — PAT (at-…) auth broke for me a few days ago and a freshly-minted token gets the same 401. The response carries x-openai-internal-caller: unknown_through_ide.

The OAuth workaround doesn't work in my case. codex login sends me to auth.openai.com, which forces phone verification — but my phone number is already linked to my personal OpenAI account, so it returns "phone number taken" and I can't complete sign-in for my work/Business account. So I'm fully locked out: PAT is rejected server-side, and OAuth dead-ends at a phone-verification collision because the number is tied to a different (personal) account.

Two questions for the maintainers:

  1. Is PAT-based Codex access being intentionally restricted in favor of OAuth, or is this a regression? (It worked until ~June 22.)
  2. Is there an OAuth path that doesn't require phone verification / that lets you select the work account when your phone is already associated with a personal account? Right now there's no way for me to authenticate the account that actually holds the Business/Codex access.

codex doctor's network remediation is misleading here — the endpoint is reachable; it's purely an auth/access-enforcement rejection.

subscriber-salibi · 25 days ago

I have the exact same problem. Login with Device Code works but is inconvenient for my setup.

Update: The issue was solved for me as mysteriously as it appeared. websocket does not show a warning in codex doctor anymore. I guess it was fixed on the backend?

efrazer-oai contributor · 25 days ago

This should now be fixed, apologies for the error.

adulau · 25 days ago

The issue still persists with the latest version of codex v0.142.2.

~~~
unexpected status 401 Unauthorized: Unauthorized, url: https://api.openai.com/v1/responses, cf-ray: a116970eaff7ba60-BRU, request id: req_b145775e30b34a24b60d8e126ec647d2, auth error: 401, auth error code:
no_matching_rule
~~~

subscriber-salibi · 21 days ago

This is working very inconsistently. Subsequent calls pass and fail seemingly randomly.

› Just say Hi!


⚠ Falling back from WebSockets to HTTPS transport. unexpected status 401 Unauthorized: Unknown error, url: wss://chatgpt.com/backend-api/codex/responses,
  cf-ray: <redacted>, auth error: 401, auth error code: no_matching_rule

• Hi!


› Just say Hi!


■ unexpected status 401 Unauthorized: Unauthorized, url: https://chatgpt.com/backend-api/codex/responses, cf-ray: <redacted>, auth error: 401,
auth error code: no_matching_rule
LousForEurt · 19 days ago

It's worked for me:

~/.codex/auth.json
from

{
  "auth_mode": "apikey",
  "OPENAI_API_KEY": "at-…"
}

to

{
  "OPENAI_API_KEY": null,
  "personal_access_token": "at-…"
}