Skip to content
Nilay Kabariya

Entry No.114·Agents··6 min read

Codex: Error loading config.toml, each message and its fix

Codex CLI 0.171.0 won't start on a bad config.toml. Common mistakes tested on Linux and Windows, from Windows paths to profiles: each message and fix.

by Nilay#codex#mcpAGENTS

The error, verbatim

Jump to the fix ↓
Error loading config.toml:
D:\a\_temp\work\codexhome\config.toml:2:16: too few unicode value digits, expected unicode hexadecimal value
  |
2 | command = "C:\Users\me\server.exe"
  |                ^
✓ Reproduced on GitHub Actions ubuntu-latest and windows-latest, November 23,

The fix that worked

For a Windows path, use single quotes (a TOML literal string):

command = 'C:\Users\me\server.exe'
Not it? Every cause, tested ↓

Tested on

Codex CLI
0.171.0
Node
24.22.3
OS
GitHub Actions ubuntu-latest and windows-latest, November 23, 2026

Error loading config.toml means Codex could not read ~/.codex/config.toml (or %USERPROFILE%\.codex\config.toml on Windows), so it stops before it does anything else. The text after it says what went wrong, and for a TOML syntax mistake it also gives the line and column (config.toml:2:16) and points at the spot with a ^.

I wrote each mistake below, and three profile setups, into a throwaway CODEX_HOME, one at a time, and ran codex exec 0.171.0 on Linux and on Windows. Both printed the same messages; only the file path differed.

Find your message

What Codex printed What was in config.toml Fix
too few unicode value digits, expected unicode hexadecimal value a Windows path in double quotes: "C:\Users\me\server.exe" single quotes 'C:\Users\me\server.exe', or doubled backslashes "C:\\Users\\me\\server.exe"
invalid basic string, expected `"` a string with no closing quote close the quote
Failed to read config file ...: invalid utf-8 sequence of 1 bytes from index 0 the file saved as UTF-16 save it as UTF-8
invalid type: integer `5`, expected a string then in `model` model = 5 quote the value: model = "..."
unknown variant `sometimes`, expected one of ... then in `approval_policy` a value that isn’t allowed use one from the list it prints
duplicate key, pointing at a [table] the same [mcp_servers.demo] table twice merge them into one table
duplicate key, pointing at a key the same key twice keep one
invalid transport then in `mcp_servers.<name>` an MCP server with no command (and no url) add command (or url) to that server
Error: legacy `profile = "work"` config is no longer supported profile = "work" at the top of config.toml move the settings into work.config.toml next to config.toml, then run codex --profile work

Not an error: a misspelled key (modle) only printed a warning and Codex carried on, and a UTF-8 file with a byte-order mark was read normally.

Windows paths: “too few unicode value digits”

This is the one Windows users hit, usually in an MCP server’s command or args:

[mcp_servers.demo]
command = "C:\Users\me\server.exe"
Error loading config.toml:
D:\a\_temp\work\codexhome\config.toml:2:16: too few unicode value digits, expected unicode hexadecimal value
  |
2 | command = "C:\Users\me\server.exe"
  |                ^

In a TOML string in double quotes, a backslash starts an escape, and \U means “a Unicode character follows as 8 hex digits”. s is not a hex digit, so the parser stops at column 16, right after \U.

Either of these was read without an error on Linux and Windows:

command = 'C:\Users\me\server.exe'      # single quotes: a literal string, no escapes
command = "C:\\Users\\me\\server.exe"   # double quotes with each backslash doubled

A file saved by PowerShell: “invalid utf-8 sequence”

Codex reads config.toml as UTF-8. In Windows PowerShell 5.1, > and Out-File write UTF-16. I checked that on Windows 11 with powershell -NoProfile: both files started with the bytes FF FE, then two bytes per character. A config.toml written as UTF-16 gave:

Error loading config.toml: Failed to read config file D:\a\_temp\work\codexhome\config.toml: invalid utf-8 sequence of 1 bytes from index 0

Save the file as UTF-8. In PowerShell 5.1, Out-File -Encoding utf8 writes UTF-8 with a byte-order mark (the bytes EF BB BF first, checked the same way), and Codex 0.171.0 read such a file normally: its model setting was applied. In an editor, pick “UTF-8” in the save dialog or the status bar.

The test file was made with iconv -t utf-16 on the runner, not by PowerShell itself (Git Bash’s iconv, GNU libiconv, wrote big-endian UTF-16, FE FF first, when I checked it on Windows 11; PowerShell writes FF FE); either way the message names byte 0, the first byte of the byte-order mark.

Wrong values: “invalid type” and “unknown variant”

A value of the wrong type names the key on the next line:

Error loading config.toml: invalid type: integer `5`, expected a string
in `model`

A setting that takes one of a fixed set of words lists them:

Error loading config.toml: unknown variant `sometimes`, expected one of `untrusted`, `on-failure`, `on-request`, `granular`, `never`
in `approval_policy`
Error loading config.toml: unknown variant `full`, expected one of `read-only`, `workspace-write`, `danger-full-access`
in `sandbox_mode`

Copy a value from the list in the message. The lists above are what 0.171.0 accepts; other versions may differ, so trust the message over a blog post or an old config.

An MCP server with no command: “invalid transport”

[mcp_servers.demo]
args = ["x"]
Error loading config.toml: invalid transport
in `mcp_servers.demo`

An MCP server in config.toml is either a local process (command) or an HTTP server (url); with neither, Codex has no transport to use. The message names the server, so check that table for a missing or misspelled command.

The same table or key twice: “duplicate key”

Error loading config.toml:
D:\a\_temp\work\codexhome\config.toml:3:14: duplicate key
  |
3 | [mcp_servers.demo]
  |              ^^^^

One easy way to get it: pasting a second copy of a server’s table below the first. The line number points at the second copy. Merge the two tables into one (or keep one of two keys with the same name: model twice gave the same message, pointing at the second model).

profile = “work”: “no longer supported”

A config.toml that picks a profile at the top level fails at start in 0.171.0:

profile = "work"
Error: legacy `profile = "work"` config is no longer supported; use `--profile work` with `work.config.toml` instead

Codex’s own docs date the change: “In Codex 0.134.0 and later, --profile no longer reads [profiles.profile-name] from config.toml” (Advanced Configuration). Keeping the old [profiles.work] table and passing the flag fails too:

Error loading config.toml: --profile `work` cannot be used while D:\a\_temp\work\codexhome\config.toml contains legacy `profile = "work"` or `[profiles.work]` config; move those settings into D:\a\_temp\work\codexhome\work.config.toml and remove the legacy pro…

(The test script cut that line at 260 characters.)

Put the profile’s settings in their own file next to config.toml, at the top level (no [profiles.work] header), and remove the profile = line and the [profiles.work] table from config.toml:

# ~/.codex/work.config.toml
model = "gpt-5.1"
codex --profile work

Two mistakes that did not stop Codex

For MCP servers that are configured correctly but still fail to start, see Codex MCP startup incomplete: what each failure prints.

How this was tested

GitHub Actions ubuntu-latest and windows-latest (Git Bash), November 23, 2026: Codex CLI 0.171.0 from npm, Node 24.22.3. Each case wrote one config.toml into a throwaway CODEX_HOME and ran codex exec --skip-git-repo-check "say hi". The API key was invented (sk-invented-test-key-not-real), so every run that got past the config ended with 401 Unauthorized; that 401 is how a passing case looks in the output (the profile cases hide the 401 lines and show the model: line instead). The Codex desktop app, the IDE extension and project-level .codex/config.toml files were not tested. The PowerShell byte checks were run on Windows 11 with Windows PowerShell 5.1. The script and the full output are in nk-repro/codex-config-toml, runs 45113678995 and 45114075760.

— N.K., end of entry No.114

Useful? Pass it on:Post on XFollow @EmotionalMatter

Related entries

  1. No.111

    Codex MCP startup incomplete: what each failure prints

    Codex 0.171.0 hides MCP startup errors behind a warnings count. Tested: a crash, a missing key, a bad command, an npx 404, a slow server, and the fix for each.

    > ⚠ 2 warnings · f2 to view

    AGENTS4 min
  2. No.031

    Fix: Codex CLI error "stdin is not a terminal"

    Codex CLI stops with stdin is not a terminal in scripts, pipes and CI. The command that works, and the 2 errors that come next, tested on 0.167.0.

    > Error: stdin is not a terminal

    AGENTS4 min
  3. No.030

    Fix: MCP error -32000 Connection closed / Failed to connect

    An MCP server fails with Connection closed or Failed to connect and never says why. Where the real error is hiding, and the fixes, tested in Claude Code.

    > MCP error -32000: Connection closed

    AGENTS4 min

tip: paste the exact error text