Forum Discussion
Cannot Release Lock on SharePoint Online File
- Jul 17, 2018
Locks is a complex topic and technically a client or network issue. SharePoint supports co-authoring locks unless you have Check In/Out enabled on the library. Client side locks will occur if Office cannot negotiate a co-author lock falling back to an exclusive lock. As others have pointed out, the upload center can contribute to locking and is one of the first things you should check. You can trace the calls via Fiddler on the client.
This is the technical explanation from PSS:
When a user attempts to open an Office file hosted on SharePoint in the Office client, there is an expected set of network calls we should be seeing unless there is a problem. Once a user clicks that Office file to open in client, code on the SharePoint page and (if using Internet Explorer) the Office 365 browser addon sends a command to initialize the client application (Word, Excel, PowerPoint). Once the Office client application starts launching, Office will start a HTTP conversation with SharePoint. If the Office call is already authenticated, the Office will be returned the file content. However, if not already authenticated, which is usually expected to be the case, Office will negotiate for Authentication with SharePoint. This process happens through two networking calls called OPTIONS calls. The first OPTIONS call is anonymous and expected to be rejected by SharePoint as to establish what types of authentication SharePoint will accept. The second options call will include the requested authentication information to SharePoint. If SharePoint accepts the second options, call, it will return a METHOD call, identifying what network verbs can be used to communicate with it (OPTIONS, GET, LOCK, PROPFIND, and POST are all examples of verbs for this process). Once the verbs are established the Office client will make a POST network call that requests the metadata for the file, adds the user’s session lock state (coauthor lock or exclusive lock) and to request to open the file from the CellStorage web service in SharePoint. If the Office client has never accessed the document before, the entire document will be downloaded from SharePoint and cached in the Office Document Cache. If the Office client has opened the file before, then it is already cached and only the changes will be downloaded. At this point, the Office file will open in the Office client. This entire process happens between a few milliseconds to a few seconds.
The solution I found was to Restore the locked out file to a previous version. That essentially kicks the user (who the file thinks is editing) out and allows you to then rename/ delete/ move etc the file again.
This is a persistent issue with something fundamental to Office 365 and seriously needs looking in to by Office Microsoft !!
- Andrew SilcockSep 25, 2018Steel ContributorThanks for the fix, I will try this next time! Be nice for a permanent fix by Microsoft though........
- Charles BoisseauNov 05, 2018Copper Contributor
Doesn't work for me.
I'm on a Mac. Using Chrome. A file I opened and edited is still locked by me. No one else has worked on it. I closed the browser. I shut Word. There is no unlock option. Does someone have step-by-step instructions to close a file that a ghost of myself has locked?
- David DeKeizerNov 06, 2018Copper Contributor
This problem is a result of Office Client setting a 'lock'.. that isn't a SharePoint check-out lock, and a network glitch misses clearing the lock. SharePoint usually notices within 15 or 20 minutes.. but not always.
I found a way to release this lock on-premises using PowerShell. I would think there is a PnP version that does the same on SPO.
I neglected to document where I plagiarized this from, so I cannot credit the original author
====================#this script overrides a file lock that occasionally occurs when a file is opened in the client, but is closed unexpectantly.
# locks are supposed to expire after 10 minutes, but that doesn't always happen
# in this case, the file looks like it is checked in, but is locked for editing$url = "https://WEBSITE/URL/HERE"
$fileurl = "https://WEBSITE/URL/HERE/LockedFileName.xlsx"
$web = Get-SPWeb $url
if($web -ne $null)
{
$item = $web.GetListItem($fileurl)if($item -ne $null)
{
Write-Host "Found file " $item.Title
$item.File.CheckOutStatus$item.ReleaseLock
#$item.File.ReleaseLock($item.File.LockId)$userId = $item.File.LockedByUser.ID
$user = $web.AllUsers.GetById($userId)$impSite = New-Object Microsoft.SharePoint.SPSite($web.Url, $user.UserToken);
$impWeb = $impSite.OpenWeb();
$impItem = $impWeb.GetListItem($fileurl)$impItem.File.ReleaseLock($impItem.File.LockId)
$impWeb.Dispose()
$impSite.Dispose()
$item.File.CheckOutStatus
}
$web.Dispose()}
=============
- David PhillipsApr 29, 2019Steel Contributor
The problem with files getting locked still happening in April of 2019. Found out the hard way after opening a file in Teams using "Open in Word", editing for 45 minutes only to notice it was "Read Only". Found a file stuck in the upload center on Pending. Removed it, fortunately I had saved the Read Only version to a local file and was able to copy and paste.
This seems to happen more often than not when editing files in SP Online. As an admin I kinda get what's going on. But this will drive users nuts.
- David_Coyle1981May 06, 2020Copper Contributor
Charles Boisseau Just experienced the same issue with a user. To remedy I cleared the cache in Microsoft Upload Centre, no luck. Then I cleared the cache in Microsoft Upload Centre 2013, no luck. Then I cleared the internet history and cache, no luck. Then I stopped the users One Drive Sync, Success!
The user had accidentally clicked on the "Sync" button at the top of the library which had created a folder in One Drive which had not yet synced with SharePoint. I removed the synced folder from one drive to prevent this recoccuring.
Not sure if any of the actions I took prior to stopping the One Drive sync had any effect, but the above resolved the issue.
- MattStOngeMay 15, 2020Copper Contributor
2020 baby yeah!
I have tried every singe suggestion in this thread.
I go to Sharepoint and go to the excel file. All good Now it's time to open in excel. Nah mate! Locked by another user.
Then I ask myself... Why and now? This is Sharepoint and I can work away just find when on the document in Sharepoint. It's not locked and I can open in excel with any other user without an issue.
I can't check it out- I get an error and it only allows me to see a portion of the error
This is just stupid. Why isn't this fixed yet?
Why do we have to mess around with a bunch of workarounds that don't even work?
- TerriHamiltonMay 24, 2019Copper Contributor
This is also what I usually have to do is open a previous version. I usually get lucky and it shows me having opened one earlier that day when it locked. But on the rare occasion it does not, and I am forced to open an older one and loose data. Michael Butterfield