Claude Code "ENOSPC: no space left on device, mkdir" fix
Claude Code ENOSPC: no space left on device, mkdir means the temp volume is full. Check df -h and df -i, then free it or set CLAUDE_CODE_TMPDIR.
ENOSPC: no space left on device, mkdir '/tmp/claude-501'Claude Code could not create the private temp directory (/tmp/claude-<uid>) it makes at startup. The volume holding it, usually /tmp, is out of space or inodes, or your disk quota on it is used up. Free that volume, or point CLAUDE_CODE_TMPDIR at a directory on another volume with room.
[1] The wording depends on the version. The operating-system text above is the form before v2.1.309; newer versions explain the cause in a sentence. The fixes are the same.
| Message | When |
|---|---|
Claude Code's temporary directory /tmp/claude-501 could not be created: the volume holding /tmp is full (ENOSPC). … | The temp directory could not be created at startup. Claude Code exits with code 1 |
… your disk quota on the volume holding /tmp is used up (EDQUOT) | The volume has room, but your quota does not |
The command was not started: this computer's disk is full (ENOSPC) on the volume holding … | Mid-session, the file that captures a Bash command's output could not be created, so nothing ran |
Disk full: · Disk quota used up: · Nearly out of inodes: | The command ran, exited nonzero, and its output may be lost |
Messages ending in Refusing to use it (owned by another user, a symlink, unreadable) are about permissions, not space; go to step 7.
[2] Check both space and inodes on the directory named in the message. Either one running out gives the same No space left on device.
$ df -h /tmp$ df -i /tmp[3] How to read the results. The following was produced on purpose in a container with a 1MiB, 64-inode tmpfs mounted on /tmp. First, space runs out.
$ dd if=/dev/zero of=/tmp/fill bs=64k count=32 status=nonedd: error writing '/tmp/fill': No space left on device$ df -h /tmpFilesystem Size Used Avail Use% Mounted ontmpfs 1.0M 1.0M 0 100% /tmp$ mkdir /tmp/claude-1000 && echo createdcreated$ echo hi > /tmp/claude-1000/out.txtbash: line 1: echo: write error: No space left on deviceHere the directory was created, but writing a file inside it failed. Claude Code captures command output in files under its temp directory, so mid-session this shows up as The command was not started or Disk full:.
Next, the number of files uses up the inodes. df -h says 0%, yet no directory can be created.
$ df -h /tmpFilesystem Size Used Avail Use% Mounted ontmpfs 1.0M 0 1.0M 0% /tmp$ df -i /tmpFilesystem Inodes IUsed IFree IUse% Mounted ontmpfs 64 64 0 100% /tmp$ mkdir /tmp/claude-1000mkdir: cannot create directory '/tmp/claude-1000': No space left on deviceDon't stop at df -h and wonder why there is room; read IUse%. When inodes are full, you have to delete many small files, not a few big ones, because each file takes one inode regardless of size.
[4] Free the volume. To find what is taking the space, follow Find what is using the space when a disk is full.
[5] If you can't free space right away, move the temp directory to another volume. Claude Code appends claude-<uid>/ to the path you give.
$ mkdir -p ~/.cache/claude-tmp$ CLAUDE_CODE_TMPDIR=~/.cache/claude-tmp claudeTo keep it, export it in your shell profile, or put it in the env block of your user settings ~/.claude/settings.json (or managed settings). In the env block of project settings (.claude/settings.json) or local settings (.claude/settings.local.json) this variable is ignored, and the error stays. Per the official docs, the default is /tmp on macOS and whatever os.tmpdir() returns on Linux. If the path in the message is not what you expected, redo step 2 against that path.
[6] EDQUOT or Disk quota used up: means your quota is used up even if the volume shows free space. Delete your own files on that volume that you no longer need.
[7] Handle the Refusing to use it forms like this.
| Part of the message | Fix |
|---|---|
is not a directory (may be an attacker-planted symlink) | Remove the entry itself, not what the link points to |
is owned by uid 502, expected 501 | Only an administrator or that user can remove it. Meanwhile use CLAUDE_CODE_TMPDIR |
is not readable | chmod 0700 /tmp/claude-<uid>, or remove it and start again |