sharepoint Code File Locked Error

How to Fix SharePoint Error File Locked Error

Diagnostic Procedures

  • 1 Understand the Causes of SharePoint File Locked Errors
  • 2 Step 1: Terminate Stuck Office Sessions
  • 3 Step 2: Clear Office Document Cache
  • 4 Step 3: Force Release Locks in SharePoint Web
  • 5 Step 4: Resolve Sync-Related Upload Locks

How to Fix SharePoint Error File Locked Error

Encountering a File Locked Error in SharePoint (often showing as “This file is locked for editing by [username]” or “The file is currently locked by another user”) occurs when SharePoint places a write-protection lock on a document. This is designed to prevent data loss during concurrent edits, but the lock can remain stuck even after the editor has closed the document.

This guide explains how to clear local application locks, flush cached documents, and release server-side locks.


Understand the Causes of SharePoint File Locked Errors

SharePoint file locks are usually caused by:

  1. Orphaned Sessions: The user’s Office application (Word, Excel, or PowerPoint) crashed or disconnected before releasing the lock on the server.
  2. Short-Term Edit Locks: SharePoint applies a schema lock (typically lasting 10 to 30 minutes) when a file is opened in a desktop app, which sometimes fails to self-expire.
  3. Sync Client Interference: The OneDrive sync client is actively uploading metadata or version histories, creating a temporary file-system lock.
  4. Co-authoring Failure: Real-time co-authoring sync is interrupted due to network packet drops, causing the server to hold a user’s lock.

Resolving SharePoint File Locked Errors

Follow these methods to unlock files and restore edit access:

Step 1: Terminate Stuck Office Sessions

If your local system is holding the lock, force-close all Office applications to kill the active file handles.

On Windows:

  1. Open the Command Prompt as Administrator.
  2. Run the following command to terminate Word, Excel, and PowerPoint processes:
:: Force quit Microsoft Office suite programs
taskkill /f /im winword.exe
taskkill /f /im excel.exe
taskkill /f /im powerpnt.exe
taskkill /f /im msosync.exe

On macOS:

  1. Open the Terminal application.
  2. Run the following command to kill corresponding processes:
# Terminate Microsoft Office applications on macOS
killall "Microsoft Word" 2>/dev/null
killall "Microsoft Excel" 2>/dev/null
killall "Microsoft PowerPoint" 2>/dev/null

Step 2: Clear Office Document Cache

The Office Upload Center or Microsoft Office Document Cache can get stuck in a loop, holding files in a locked state.

On Windows:

Run these commands in the Command Prompt to wipe the local file cache database:

:: Remove the Microsoft Office File Cache folder
rmdir /s /q "%LocalAppData%\Microsoft\Office\16.0\OfficeFileCache"

On macOS:

Run this command in the Terminal:

# Clear the cache directories for Office components
rm -rf ~/Library/Group\ Containers/UBF8T346G9.Office/OfficeFileCache-*

Step 3: Force Release Locks in SharePoint Web

If the server thinks a user still has the file open, you can force the lock release via the web interface.

Option A: Check Out and Check In (Site Owner or Admin)

  1. Navigate to the SharePoint document library in a browser.
  2. Right-click the locked file, select More > Check out. This overrides other user locks.
  3. Right-click the file again, select More > Discard checkout (or check it back in). This forces the server to release the lock state.

Option B: Wait for the Token to Expire

Short-term locks on the SharePoint server automatically expire after 10 to 15 minutes of inactivity. Ensure the user mentioned in the error closes all browser and desktop instances of the document, and wait for this period to pass.


If the file is locked by a sync operation, resetting OneDrive will release the file handle.

On Windows:

%localappdata%\Microsoft\OneDrive\onedrive.exe /reset

On macOS:

open /Applications/OneDrive.app/Contents/Resources/ResetOneDriveAppStandalone.command

Summary Checklist

  • Check who is holding the lock (displayed on the error page).
  • If it is your account, force-quit Office apps and clear the Office File Cache.
  • Ask the lock holder to close the file or disconnect their network connection temporarily.
  • Perform a Check Out -> Discard Check Out sequence on SharePoint to break the lock.
  • Reset the local OneDrive sync client to clear stuck upload operations.