When Claude Code on Windows can’t save, replace or delete a file and reports „The process cannot access the file because it is being used by another process“, it’s not a Claude bug but a classic Windows file lock: a running process – usually node.exe or python.exe from a dev server or watcher the agent started – is holding the file open. Here’s how to find and stop it.
- What the error means
- Why it happens with Claude Code
- Quick fix: kill the process
- Precisely: which process locks the file?
- When no node/python is running
- Special case: install/update
- Preventing it
- FAQ
What the error means
Windows lets a program open a file with an exclusive lock. While that lock is held, no other process may overwrite or delete the file – the system returns „The process cannot access the file because it is being used by another process“ (internally ERROR_SHARING_VIOLATION, error code 32). Node.js surfaces this as EBUSY or EPERM. Claude Code’s write, edit and delete tools run straight into it.
This is Windows behaviour. On Linux and macOS the error is rare, because files there can usually be replaced even while a handle is still open.
Why it happens with Claude Code
In almost every case a process that Claude Code (or you) started earlier is holding the file open. Typical culprits:
- A running dev server:
npm run dev, Vite, Next.js,nodemon– runs asnode.exeand constantly touches project files. - Test watchers:
jest --watch,vitest,pytest-watch. - Python servers:
uvicorn, Flask,django runserver– run aspython.exe/pythonw.exe. - Build/bundler processes still running in the background.
- Antivirus/Defender scanning the freshly written file.
- Cloud sync (OneDrive, Dropbox) or the file open in an editor.
Which process it is depends on what the agent was working with: in a JavaScript/TypeScript project (npm, pnpm, Vite, Next.js) it’s node.exe; in a Python project (uvicorn, Flask, Django, pytest) it’s python.exe.
Quick fix: kill the blocking process
The fastest fix is to stop the relevant interpreter, then simply re-run the action in Claude Code.
Node.js projects
REM Command Prompt (CMD)
taskkill /IM node.exe /F# PowerShell
Stop-Process -Name node -ForcePython projects
REM Command Prompt (CMD)
taskkill /IM python.exe /F
taskkill /IM pythonw.exe /F# PowerShell
Stop-Process -Name python -Force/F (or -Force) kills the process hard. Only unsaved in-memory data is lost – harmless for dev servers and watchers, and your source code on disk is untouched. If several Node projects run at once, taskkill /IM node.exe /F stops them all; to hit just one, use the precise method below.
Precisely: which process locks the file?
Instead of killing every Node or Python process, you can pinpoint the exact one.
With Resource Monitor (resmon)
- Press
Win+R, typeresmon, hit Enter. - Open the CPU tab and expand Associated Handles.
- Type the file name (or part of the path) into the search box.
- Read the Image (process name, e.g.
node.exe) and PID from the results.
Kill the process by PID
REM CMD
taskkill /PID 12345 /F# PowerShell
Stop-Process -Id 12345 -ForceFind a dev server by its port
netstat -ano | findstr :3000
REM last column is the PID, then:
taskkill /PID <PID> /FOptional: Sysinternals Handle
Microsoft’s free Sysinternals tool handle shows on the command line which process holds a file open – the CLI counterpart to Process Explorer:
handle64.exe myfile.txtWhen no node/python is running: other causes
- Antivirus/Defender real-time scan: wait briefly for the scan to release the file, or add the project folder as an exclusion (trusted projects only).
- OneDrive/Dropbox sync: pause syncing or move the project out of the synced folder.
- File open in an editor/VS Code/Excel: close it.
- A second terminal whose working directory is in that folder: close it or change directory.
- Last resort: restart the terminal or Claude Code session – and if nothing helps, reboot. That releases every lock.
Special case: install or update errors
If the message appears while installing or updating Claude Code, then per the official Claude Code documentation the virus scanner is usually locking a partially downloaded binary. Clear the downloads folder and re-run the installer:
# PowerShell
Remove-Item "$env:USERPROFILE\.claude\downloads\*" -Recurse -ForceAlso close other installer/PowerShell windows, wait for the AV scan, and – in enterprise setups – have claude.exe plus the processes it spawns (cmd.exe, bash.exe) allowlisted in AppLocker/EDR.
Preventing it in future
- Run dev servers and watchers in a separate terminal you control – not the one Claude Code works in.
- Stop the watcher briefly before large multi-file edits.
- Kill background dev servers Claude Code started before letting it edit the same files.
- Keep project folders out of OneDrive/Dropbox – or set a sync exclusion.
- Add trusted project folders to your Defender exclusions to reduce scan-induced locks.
FAQ
Do I really have to force-kill node.exe or python.exe?
For dev servers and watchers, yes – it’s harmless. Only unsaved in-memory data is lost, not your source code on disk. Just restart the server afterwards.
Is this a bug in Claude Code?
No. It’s standard Windows behaviour for exclusive file locks, which is why it barely occurs on Linux and macOS.
How do I know whether node or python is to blame?
By what was being worked on: a JavaScript/TypeScript project → node.exe; a Python project → python.exe. When in doubt, Resource Monitor shows the exact process.
Does rebooting help?
Yes, as a last resort – it releases every lock. But a targeted taskkill is faster and doesn’t disrupt the rest of your workflow.
Sources: Claude Code Docs – Troubleshoot installation · Winhelponline (Resource Monitor) · The Windows Club.

