Skip to main content

Codex Credentials Could Not Be Saved Locally: 3 Causes and Fixes

Your sign-in worked; Codex couldn't write auth.json. OS error 1307: log out and in with the bundled codex.exe. Hard-linked or read-only file: fix the file.

LaoZhang AI TeamPublished11 min read
On this page
Codex persist_failed: sign-in worked but saving auth.json failed; OS error 1307, hard-linked files and read-only each lead to their own fix

"Sign-in could not be completed. Sign-in completed but credentials could not be saved locally." with Error code: persist_failed means your ChatGPT account and the browser sign-in are fine. Codex received your tokens and then failed to write them into its credential file, auth.json, on this computer. "Credentials" here is that local file, not your password, so changing your password won't help, and repeating the same sign-in in the app fails again until the local cause is fixed. The Details: line under the error code tells you which local problem stopped the write.

If Details ends in (os error 1307) on the Windows desktop app, find the codex.exe that ships with the app, run its logout and then login from a regular PowerShell window, and reopen Codex. Users on GitHub and the OpenAI forum confirmed this workaround five times between November 11 and December 6, 2026, although OpenAI has not explained the error. If Details says atomic credential replacement does not support hard-linked files, another path on your disk is a hard link to auth.json, for example one made by claude-mem 16.0.0 on Windows; remove that extra link and sign in again. If it says credential file is read-only or Permission denied (os error 13), make auth.json and its .codex folder writable.

Users who hit OS error 1307 tried Repair, Reset, uninstalling and reinstalling, rebooting and a config.toml setting first, and none of those cleared it. If the matching fix fails, the last section covers what to add to the open GitHub issue.

What "credentials could not be saved locally" means for your account

The failure happens after the server has already accepted your sign-in. A string search of the Codex CLI 0.166.0 binary on November 23, 2026 found the sign-in error codes in the order the steps run: missing_authorization_code, workspace_restriction, token_exchange_failed, then persist_failed with this exact sentence, then redirect_failed. So by the time you see persist_failed, the code from your browser was successfully exchanged for tokens; only the save on your machine went wrong.

The same check found that packaged Codex clients default to cli_auth_credentials_store = "file", which stores ChatGPT sign-in credentials as a plain file, auth.json, in the Codex home folder: ~/.codex on macOS and Linux, %USERPROFILE%\.codex on Windows, or whatever CODEX_HOME points to. The desktop app ships its own copy of the Codex CLI and uses the same folder, which is why the CLI commands below can repair a desktop sign-in.

If your error code is token_exchange_failed instead, the problem is one step earlier, and Codex Token Exchange Failed 403 and Error Sending Request Fixes covers it. If the browser shows "localhost refused to connect" on a remote or headless machine, see Codex Headless Login: Device Code, SSH Tunnel, or auth.json. A 401 after a sign-in that did save is a different failure, covered in Codex 401 Incorrect API Key: Outage, Stale Token, or Your Key?.

Read the text after Details: and find it in the first column below. That line, more than which Codex client you use, decides the fix.

Details lineWhere it shows upWhat is wrongFixHow sure
This security ID may not be assigned as the owner of this object. (os error 1307)Codex desktop app on WindowsWindows refused to set a file owner (ERROR_INVALID_OWNER); why Codex hits it is unknownLog out and in with the bundled codex.exe, reopen the appCommunity workaround, five user confirmations; open bug, no OpenAI reply as of December 6, 2026
atomic credential replacement does not support hard-linked filesAny Codex client built on CLI 0.167.0 or laterauth.json has a second hard link somewhereRemove the extra link (update claude-mem if it made it), sign in againCertain: Codex source and a reproduction on December 6, 2026
credential file is read-onlyCodex CLI 0.167.0 or laterauth.json is marked read-onlyMake the file writable, sign in againCertain: Codex source and a reproduction on December 6, 2026
Permission denied (os error 13)Older clients, or a .codex folder you can't write toNo write permission on the file or its folderFix permissions or ownership of .codexReproduced on CLI 0.166.0 on November 23 and December 6, 2026

Microsoft's list of Windows system error codes 1300–1699 defines 1307 as ERROR_INVALID_OWNER, which is where the "security ID" wording comes from. It doesn't mean your Windows account or your ChatGPT account is damaged.

OS error 1307 on Windows: sign in with the bundled codex.exe

On the Windows desktop app, the fix that has worked is to sign in once through the command-line tool that ships inside the app, then let the app pick up the saved session. It was first reported on the OpenAI Developer Community thread about persist_failed and error 1307 on November 11, 2026, and confirmed again in GitHub issues openai/codex #61093 and #65349; the reporter of #65349 counted five confirmations on December 6, 2026. You don't need to install anything first.

  1. Close the Codex app. Open PowerShell normally, not with "Run as administrator"; the reports that worked used a regular window.

  2. Find the bundled CLI. It is often not at %LOCALAPPDATA%\OpenAI\Codex\bin\codex.exe but one folder deeper, in a version folder with a random-looking name such as bin\9e1da79431da526b\. This lists every copy:

    powershell
    Get-ChildItem $env:LOCALAPPDATA\OpenAI -Recurse -Filter codex.exe
  3. Log out with the full path from that list, in quotes after &:

    powershell
    & "$env:LOCALAPPDATA\OpenAI\Codex\bin\<version-folder>\codex.exe" logout
  4. Log in with the same path, replacing logout with login. Finish the sign-in in the browser; it shows "Signed in to Codex. You may now close this page", and PowerShell prints Successfully logged in.

  5. Open the Codex app. If a banner asks you to complete Windows setup before it can create files or run actions, click Continue.

  6. Quit Codex completely, make sure it is gone from the system tray and Task Manager, and open it again. You should still be signed in.

Six steps to fix OS error 1307 in the Codex Windows app: close Codex, find the bundled codex.exe in its version folder, log out, log in and finish in the browser, click Continue on the setup banner, then quit fully and reopen

The reporter of #65349 had already tried Repair, Reset, uninstalling, reinstalling and rebooting on Codex runtime v26-1201-1055-0, and none of them helped; on December 6, 2026 the CLI login fixed it, and the app opened with its full conversation history and stayed signed in after a full quit and reopen. Whether that holds across a Windows restart had not been reported yet. If Codex won't close cleanly before step 6, Codex Windows Background Processes: What to End and What to Leave Running explains which processes to end.

OpenAI hasn't said why the desktop app's save returns 1307 while the bundled CLI's save works, and the reporters' guesses about the cause are not confirmed. Treat this as a workaround: if the error returns after an update, run the same two commands again.

Repair, Reset and reinstalling didn't clear persist_failed for users

In the Windows 1307 reports, the usual app fixes didn't help. Forum users on November 11, 2026 said Repair, reinstalling and setting cli_auth_credentials_store = "file" left the error in place, and the #65349 reporter tried Repair, Reset, a full uninstall and reinstall, and a reboot on runtime v26-1201-1055-0 with the same result. That reporter also checked that the app's package folder was owned by their user with Full control, and that Windows Credential Manager held no stale OpenAI entry, and still got 1307. So skip these and go straight to the bundled codex.exe steps above.

OpenAI hasn't explained why these don't work. One possible reason, not confirmed: the credential file lives in the Codex home folder (%USERPROFILE%\.codex by default), which isn't part of the app package these tools reset. The config.toml setting is easier to explain, because packaged Codex clients already store credentials in that file by default, so setting it to "file" only restates the current behavior.

Fix "atomic credential replacement does not support hard-linked files"

This line means auth.json has more than one name on disk. A hard link is a second path to the same file data, so the two paths are equal copies of one file, unlike a shortcut or symlink, which only points to the real file. Since Codex CLI 0.167.0, Codex saves credentials by writing a temporary file next to auth.json and renaming it over the old one, so nothing ever reads a half-written file; with a hard link, that rename would leave the other path holding the old tokens. The Codex credential storage source refuses instead, on Windows too, and says so in its header: "Symlinks retain their target; hard links and read-only files fail rather than split identity."

Hard link vs symlink for Codex auth.json: two paths to the same file data are refused with the hard-linked files error, while a symlink saves because Codex rewrites the file it points to

On December 6, 2026, the error reproduced on macOS with Codex CLI 0.174.0, a throwaway CODEX_HOME and dummy API keys. After adding a second hard link to auth.json, codex login --with-api-key printed Error logging in: atomic credential replacement does not support hard-linked files. Deleting the extra link made the next login save normally, and replacing auth.json with a symlink also worked: Codex rewrote the file it points to. That test used API-key login on a Mac; the ChatGPT browser sign-in and Windows were not run, so the full Windows dialog wording comes from user reports.

One known source of the extra link is claude-mem. With its Codex provider on Windows, claude-mem 16.0.0 hard-linked your auth.json into a private Codex home under %TEMP%\claude-mem-codex-app-server-*\codex-home\, as described in claude-mem issue #6331. Version 16.0.1, released November 19, 2026, no longer does that. Any other tool, backup or sync script that hard-links the file has the same effect.

  1. List every path of the file. On Windows, in Command Prompt:

    bat
    fsutil hardlink list %USERPROFILE%\.codex\auth.json

    In PowerShell, use "$env:USERPROFILE\.codex\auth.json" as the path. On macOS or Linux, ls -l ~/.codex/auth.json shows the link count in the second column, and find ~ -samefile ~/.codex/auth.json prints every path of that file within your home folder.

  2. If a second path is under claude-mem-codex-app-server-*, update claude-mem to 16.0.1 or later; the maintainer's note gives npx claude-mem@16.0.1 install, or you can wait for its auto-update.

  3. Delete the extra path, not .codex\auth.json. fsutil prints paths without the drive letter, so add C: in front when you delete it. Deleting one name of a hard link leaves the other intact. If a tool needs to share the file, give it a symlink or a copy instead.

  4. Run step 1 again and confirm only one path is listed, then sign in to Codex again.

Running codex logout and then codex login without deleting the other path also gets you signed in. In a follow-up run of the same December 6 test, with the extra hard link left in place, logout removed only the path inside CODEX_HOME, and the next login saved a new auth.json with a link count of 1. The other path kept the old credentials and is no longer shared with Codex, so the tool that uses it keeps its stale tokens, and if that tool creates the link again, the error comes back.

"credential file is read-only" or Permission denied (os error 13)

These two lines mean Codex isn't allowed to write auth.json or its folder. In the December 6, 2026 test, CLI 0.174.0 printed Error logging in: credential file is read-only when auth.json was set to read-only (chmod 400), while 0.166.0 printed Error logging in: Permission denied (os error 13) for the same file. On November 23, 2026, CLI 0.166.0 also printed Permission denied (os error 13) when the CODEX_HOME folder itself was read-only, and wrote nothing. Because each save creates a temporary file in that folder, the folder has to be writable too, not just the file.

On macOS or Linux, check both with ls -ld ~/.codex ~/.codex/auth.json, then run chmod 700 ~/.codex and chmod 600 ~/.codex/auth.json. If the owner shown is root instead of you, for example because Codex was once started with sudo, give the folder back with sudo chown -R "$(whoami)" ~/.codex. On Windows, clear the read-only attribute with attrib -r "%USERPROFILE%\.codex\auth.json" in Command Prompt. Then sign in again.

Did a Codex update cause this? CLI 0.167.0 and later

The hard-link and read-only messages are new. The check that produces them came with Codex commit 582a8812e, dated October 30, 2026, and first shipped in CLI 0.167.0, released November 6, 2026. CLI 0.166.0 didn't have it: in the December 6 test it saved over the hard-linked file without an error and quietly split the two paths into different files. If a tool hard-linked your auth.json long ago and Codex only started failing recently, the update made an existing setup visible rather than breaking it. Run codex --version to see your standalone CLI version. Which CLI version each desktop build bundles isn't published.

The Windows 1307 reports name these desktop builds: 26.1123.101703 (build 33106), which failed on November 25 and December 5, 2026, and the December 1 runtime v26-1201-1055-0 in #65349. One user who updated to 26.1201.41126 (build 33981) kept an existing session, but a fresh sign-in on that build hadn't been reported as of December 6, 2026.

Still failing after the fix: what to add to the GitHub issue

If the matching fix doesn't hold, add your case to the open issue rather than reinstalling again. As of December 6, 2026, OpenAI hadn't replied on #61093 or #65349. For OS error 1307 on Windows, add a comment there with the full Details: line, the Codex app version and build, your Windows version, the output of the logout and login commands, and the fsutil hardlink list result, so the hard-link case can be ruled out. The in-app feedback ID is worth adding too; one reporter included theirs for the engineers. Never paste the contents of auth.json, since it holds your tokens.

If fsutil or find shows a second path that you can't trace to claude-mem, report it to whichever tool owns that folder; Codex is refusing the save on purpose, and only that tool can stop creating the link.

Codex persist_failed: other questions

Will logging out of Codex delete my conversation history?

No, based on the reports so far. In #65349, after the bundled CLI's logout and login on December 6, 2026, the Windows desktop app opened signed in with its full conversation history. codex logout removes the credential file, auth.json, not your sessions.

Yes. A copy and a symlink both work with Codex CLI 0.167.0 and later; only a hard link is refused. The December 6, 2026 test confirmed that Codex follows a symlinked auth.json and updates the real file. To set up a machine without a browser by copying the file, see Codex Headless Login: Device Code, SSH Tunnel, or auth.json.

Sources7

External pages this guide links to, in the order they appear. Last updated Dec 6, 2026.

  1. 1.list of Windows system error codes 1300–1699learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--1300-1699-
  2. 2.OpenAI Developer Community thread about persist_failed and error 1307community.openai.com/t/login-always-fails-with-persist-failed-error-1307-in-browser-solved-already/1415107
  3. 3.openai/codex #61093github.com/openai/codex/issues/61093
  4. 4.#65349github.com/openai/codex/issues/65349
  5. 5.Codex credential storage sourcegithub.com/openai/codex/blob/main/codex-rs/login/src/auth/storage_file.rs
  6. 6.claude-mem issue #6331github.com/thedotmack/claude-mem/issues/6331
  7. 7.582a8812egithub.com/openai/codex/commit/582a8812e