Skip to content

EBUSY: resource busy or locked on .claude.json with multiple concurrent instances (Windows) #25699

Closed as duplicate

Description

@callingcard1973

Bug Description

When running multiple Claude Code CLI instances and/or Claude Desktop simultaneously on Windows, writeFileSync to ~/.claude.json intermittently fails with:

ERROR  EBUSY: resource busy or locked, open 'C:\Users\apami\.claude.json'

    at writeFileSync (unknown)
    Iq (B:/~BUN/root/claude.exe:6171:1226)
    rHf (B:/~BUN/root/claude.exe:6171:4208)
    BA (B:/~BUN/root/claude.exe:6171:2887)
    <anonymous> (B:/~BUN/root/claude.exe:3797:23173)
    cA (B:/~BUN/root/claude.exe:679:62572)
    w1 (B:/~BUN/root/claude.exe:679:75521)
    ED (B:/~BUN/root/claude.exe:679:75405)
    w1 (B:/~BUN/root/claude.exe:679:76304)
    ED (B:/~BUN/root/claude.exe:679:75405)

Environment

  • OS: Windows 11 Pro 10.0.26200
  • Claude Code version: Latest (native install via .local/bin/claude.exe)
  • Claude Desktop: app-1.1.2685
  • Concurrent processes: ~14 CLI instances + ~9 Desktop app processes

Root Cause

Multiple Claude processes write to the shared ~/.claude.json file (19KB, contains telemetry counters, session stats, feature flags, project configs). On Windows, file writes acquire mandatory locks (unlike Unix advisory locks). When two processes call writeFileSync() at the same instant, one gets EBUSY.

Windows Defender real-time protection makes this worse — it briefly locks the file for scanning after each write, extending the contention window.

Suggested Fix

Replace the bare writeFileSync() with one of:

  1. Atomic write: Write to ~/.claude.json.tmp, then fs.renameSync() to ~/.claude.json — rename is atomic on both Windows (NTFS) and Unix
  2. Retry with backoff: Wrap writeFileSync in a retry loop (e.g., 3 attempts, 50-200ms exponential backoff) to handle transient locks
  3. Both: Atomic write + retry on the rename for belt-and-suspenders

Workaround

Adding a Windows Defender exclusion for ~/.claude.json and claude.exe reduces the lock window and makes collisions less frequent, but doesn't fully eliminate the race.

Add-MpExclusion -ExclusionPath "C:\Users\<user>\.claude.json"
Add-MpExclusion -ExclusionProcess "claude.exe"

Activity

  1. added
    bugSomething isn't working
    duplicateThis issue or pull request already exists
    platform:windowsIssue specifically occurs on Windows
    on Feb 14, 2026
  2. github-actions commented on Feb 14, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. EBUSY: resource busy or locked when running multiple Claude instances concurrently #20168
    2. [Bug] EBUSY: Resource locked when accessing .claude.json config file #14504
    3. [BUG] File locking on windows #15079

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  3. github-actions commented on Feb 17, 2026

    @github-actions

    This issue has been automatically closed as a duplicate of #20168.

    If this is incorrect, please re-open this issue or create a new one.

    🤖 Generated with Claude Code

  4. github-actions commented on Feb 24, 2026

    @github-actions

    This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

  5. locked as resolved and limited conversation to collaborators on Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions