ContextCleaner: see every entry in the Windows 11 right-click menu, and which app added it — on the Microsoft Store.
Windows Tips & Tools LockGhost

Error 0x80070021: "Another Process Has Locked a Portion of the File" Explained

Published October 23, 2026 Updated October 23, 2026 7 min read

Error 0x80070021 means “The process cannot access the file because another process has locked a portion of the file.” It is Windows system error 33, ERROR_LOCK_VIOLATION, wrapped as an HRESULT, and it happens when another program has locked a byte range inside the file, which is common with databases, mail stores and files opened for shared editing. The fix is to find and close the program holding the file, and LockGhost from Automata Labs shows you which process that is, by name, so you do not have to guess.

See which app is holding your file before you close anything.

Get it from Microsoft

What does error 0x80070021 mean?

The code has two parts. Microsoft’s structure of COM error codes lists facility 7 as FACILITY_WIN32, “used to provide a means of handling error codes from functions in the Windows API as an HRESULT.” The HRESULT_FROM_WIN32 macro builds the value from the system error code, the Win32 facility and a failure bit. So:

  • 0x8007 means “a failed Windows API call.”
  • 0x0021 is the system error code in hexadecimal, which is 33 in decimal.

Microsoft’s system error codes list defines it:

ERROR_LOCK_VIOLATION, 33 (0x21): “The process cannot access the file because another process has locked a portion of the file.”

How is error 33 different from error 32?

They look similar but describe different locks. The error 32 guide covers the more common one in depth.

Error 32Error 33
HRESULT form0x800700200x80070021
NameERROR_SHARING_VIOLATIONERROR_LOCK_VIOLATION
Message”…being used by another process.""…another process has locked a portion of the file.”
What is blocking youAnother program opened the whole file without sharing the access you needAnother program locked a byte range inside the file
Typical momentOpening, deleting, renaming or movingReading or writing part of the file, including copying it

With error 32, Windows refuses to open the file at all. With error 33, the file may open, but your read or write runs into a region another program has reserved.

What is a byte-range lock?

Programs can lock just part of a file with Windows functions such as LockFileEx. Microsoft’s documentation explains the two kinds:

  • An exclusive lock “denies all other processes both read and write access to the specified region of the file.”
  • A shared lock “denies all processes write access to the specified region of the file,” while all processes can still read it.

This is how databases and shared-editing apps let several users or processes work in one file without corrupting it: each locks only the records or pages it is changing. It is also why a backup or copy can fail partway through a large file that is still open in another app.

Microsoft also notes that if a process ends or closes the file without unlocking, “the locks are unlocked by the operating system,” but “the time it takes for the operating system to unlock these locks depends upon available system resources.” So error 33 can persist briefly even after the program closes.

Where does error 0x80070021 usually appear?

Because it is a generic Windows code, the same number can surface in very different places:

  • File Explorer when copying, moving or backing up a file that another program still has open.
  • Backup and sync tools that try to read a large file, such as a mailbox or database file, while its app is running.
  • Scripts and command-line tools, where you may see the decimal code 33 or the name ERROR_LOCK_VIOLATION instead of the hexadecimal HRESULT.
  • Developer tools and installers that write to a file another process is reading or writing at the same time.

The wording and the code tell you the same thing in each case: the file exists and you have permission, but part of it is reserved by another process right now.

How do I fix error 0x80070021?

Work through these in order:

  1. Close the program that uses the file. If it is a database, mail file or a document someone has open on a shared drive, close it in that app rather than force-ending it, so it can save and release its locks.
  2. Find the process if you do not know it. The error message does not name the program. A tool that shows which processes have the file open answers that directly.
  3. Wait a moment and retry after the program closes, because Windows may take a little time to release the locks.
  4. Check background tools. Sync clients, backup software and antivirus scans can have files open in the background. See antivirus locking a file and Dropbox and Google Drive locking files.
  5. For network files, the lock may be held by someone else’s PC. Ask them to close the file, or ask whoever manages the share.
  6. Restart as a last resort. It releases every lock, but you lose the chance to save work cleanly.

Avoid ending processes you do not recognize. Force-closing a database engine or mail client to break its lock can leave the file it was writing in a damaged state.

Find the process behind a file lock by name, with guardrails against ending critical system processes.

Get it from Microsoft

How does LockGhost help?

Because a byte-range lock belongs to a process that has the file open, the practical question is which process has it open. LockGhost is built to answer that. According to its Microsoft Store listing:

  • File and folder lock detection identifies the process behind “file in use,” “access denied” and “cannot delete file” errors.
  • Friendly process details replace obscure process IDs with understandable app names.
  • Safe resolution controls and guardrails help you avoid ending critical system processes.
  • Explorer-friendly workflow lets you resolve locks from your normal file management routine.
  • Local lock history lets you review recent lock events, without sending file data anywhere.
  • 100% offline, with no cloud account and no telemetry, on Windows 10 and Windows 11.

LockGhost shows you who has the file. The safest action is usually to switch to that app and close the file there. If you are weighing alternatives, compare PowerToys File Locksmith vs LockGhost or read our LockHunter alternative for Windows 11 overview.

Frequently asked questions

Is 0x80070021 a disk error?

No. It is a locking error. Windows is refusing access because another program has locked part of the file, not because the disk is damaged.

Why does copying a file give error 0x80070021?

Copying reads the whole file. If another program holds an exclusive lock on part of it, the read of that region is denied and the copy stops.

Does closing the program always fix it immediately?

Usually, but Microsoft notes the operating system may take a little time to release locks after a process ends or closes the file. Retry after a moment.

What is the difference between 0x80070020 and 0x80070021?

0x80070020 is error 32, a sharing violation on the whole file. 0x80070021 is error 33, a lock on a portion of the file.

Can LockGhost unlock a file without closing the app?

LockGhost focuses on showing which process holds the file and offering safe resolution controls. Closing the file in the app that owns it is the safest way to release a byte-range lock.

Try LockGhost

Get LockGhost from the Microsoft Store. It is a one-time purchase with no subscription, and the Store listing shows the current price.

Stop guessing which app has your file, and fix lock errors in seconds.

Get it from Microsoft

Microsoft, Windows and PowerToys are trademarks of the Microsoft group of companies. Dropbox and Google Drive are trademarks of their respective owners. LockGhost is not affiliated with or endorsed by Microsoft, Dropbox or Google.

Last updated 23 October 2026. Published by Automata Labs, a software company in Canada.

// release_radar

Get notified about new releases.

We build native, local-first tools for professionals who refuse SaaS fatigue. Drop your email to hear about new apps, major updates, and zero-telemetry releases as they land on the Microsoft Store. No spam — just release news.