Claude Code "Temp directory /tmp/claude-1000 is owned by uid 0, expected 1000. Refusing to use it"#
Published by Alex Sorokoletov
Temp directory /tmp/claude-1000 is owned by uid 0, expected 1000. Refusing to use it means something else created Claude Code's per-user temp directory before Claude Code did. Claude Code uses claude-<your uid> under the system temp root, for example /tmp/claude-1000, and refuses it when another account owns it. Point Claude Code at a directory you own with CLAUDE_CODE_TMPDIR, or delete the stale one and start again.
Why Claude Code refuses the temp directory#
On startup Claude Code creates claude-<uid> in the system temp root (TMPDIR, else /tmp), where <uid> is your numeric user ID, so a user with uid 1000 gets /tmp/claude-1000. Before it uses that directory it opens it without following symlinks and checks who owns it. If the owner is not you, Claude Code stops rather than read or write in a directory another account controls.
The common cause is a step that ran Claude Code, or pre-made the path, as a different user. A sudo claude, a container build step as root, or a shared /tmp on a multi-user box can leave /tmp/claude-1000 owned by uid 0. Your later run as uid 1000 then finds a directory it does not own and refuses it. The full message, as it reaches settings processing, is:
Temp directory /tmp/claude-1000 is owned by uid 0, expected 1000. Refusing to use it — another user may have pre-created it. Set CLAUDE_CODE_TMPDIR to a directory you control, or ask an administrator to remove it.
How to fix it#
Remove the stale directory, if you or your administrator trust what is in it:
# as its owner, or with sudo
rm -rf /tmp/claude-1000
Claude Code recreates its own temp directory on the next start and sets its mode to 0700.
Or point Claude Code at a directory you own. Set CLAUDE_CODE_TMPDIR in your shell, or in the env block of ~/.claude/settings.json:
{
"env": {
"CLAUDE_CODE_TMPDIR": "/home/you/.cache/claude-tmp"
}
}
The directory must be one you own. If it already exists with a wider mode, Claude Code tightens it to 0700; if it is on a full volume, see the table below.
Running as root inside a container#
When Claude Code runs as root (uid 0) in a container and finds the temp directory owned by another uid, set CLAUDE_CODE_CONTAINER_ID. With that variable set and the process running as root, Claude Code records a tempdir_owner_mismatch warning and uses the directory instead of stopping. This exception is for containers where ownership is expected to differ; it does nothing for a non-root user, who still gets the refusal. It arrived in v2.1.186.
The exact message for each cause#
Each cause has its own wording. Every message ends with the same line: Set CLAUDE_CODE_TMPDIR to a directory you control, or ask an administrator to remove it.
| Cause | Message | Fix |
|---|---|---|
| Directory owned by another user | is owned by uid X, expected Y. Refusing to use it — another user may have pre-created it. | Remove it, or set CLAUDE_CODE_TMPDIR; a root container sets CLAUDE_CODE_CONTAINER_ID |
| Directory yours but unreadable | is not readable (its mode may have been altered, or a path component denies search). Refusing to use it — restore its permissions (chmod 0700) or remove it. | chmod 0700 the directory, or remove it |
| Path is a symlink or not a directory | is not a directory (may be an attacker-planted symlink). Refusing to use it. | Remove the symlink, or set CLAUDE_CODE_TMPDIR to a real directory |
| Volume full when creating it | could not be created: … Free space on that volume, or set CLAUDE_CODE_TMPDIR to a directory on another one, then try again. | Free space, or set CLAUDE_CODE_TMPDIR on another volume |
Timeline#
| Version | Published | Change |
|---|---|---|
| v2.1.150 | 2026-05-23 | The ownership and symlink checks on the temp directory are in place, including the "owned by uid" refusal. |
| v2.1.186 | 2026-06-22 | The root-in-container exception arrives: with CLAUDE_CODE_CONTAINER_ID set and the process running as uid 0, a mismatched owner is used after a warning. |
| v2.1.280 | 2026-09-22 | Release notes: claude agents now shows an error instead of a blank screen when the temp directory is full, not writable, or owned by another user. |
Should you set CLAUDE_CODE_TMPDIR permanently?#
Leave the default on a single-user machine; the refusal is rare and a one-time cleanup fixes it. Set CLAUDE_CODE_TMPDIR to a directory under your home when you share /tmp with other accounts, when a build or cron step runs Claude Code as another user, or when a hardened /tmp is wiped or remounted between runs. A per-user path you own removes the ownership clash for good.
FAQ#
Q: What does "Temp directory /tmp/claude-1000 is owned by uid 0, expected 1000. Refusing to use it" mean?
A: Claude Code's per-user temp directory, /tmp/claude-1000 for a user with uid 1000, already exists and is owned by a different account (here root, uid 0). Claude Code will not use a temp directory another user owns, so it stops.
Q: How do I fix it?
A: Remove the stale directory with rm -rf /tmp/claude-1000 as its owner or with sudo, then start Claude Code again; it recreates its own. Or set CLAUDE_CODE_TMPDIR to a directory you own, in your shell or the env block of ~/.claude/settings.json.
Q: What is CLAUDE_CODE_TMPDIR?
A: The environment variable that sets Claude Code's temp directory. Point it at a directory you own to move Claude Code off /tmp/claude-<uid>. CLAUDE_TMPDIR is a fallback for the same purpose.
Q: I run Claude Code as root in a container. How do I allow the temp directory?
A: Set CLAUDE_CODE_CONTAINER_ID. With it set and the process running as uid 0, Claude Code logs a tempdir_owner_mismatch warning and uses the directory instead of refusing it. It has no effect for a non-root user.
Q: Why does it say "may be an attacker-planted symlink"?
A: That wording appears when the path is a symlink or not a directory. Claude Code opens the temp directory without following symlinks, so a symlink in its place is treated as something another process planted, and it refuses to write through it.
Q: Is deleting /tmp/claude-1000 safe?
A: It holds only Claude Code's scratch files for that session, so removing it between runs is safe. Delete it as its owner or with sudo, since the problem is that your user does not own it.
Sources: Claude Code changelog, v2.1.280
Related: CLAUDE_CODE_TMPDIR in the env-var glossary | CLAUDE_TMPDIR in the env-var glossary | Claude Code "Don't Ask Again" Saved a Password