Forum Discussion
Brent Ellis
Apr 04, 2017Silver Contributor
Cannot Release Lock on SharePoint Online File
SharePoint thinks a user still has a lock on. I can't adminsitratively do anything with the file online. This has been going on for almost a day. We've cleared cache, closed Excel on his comput...
- 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.
Michael Butterfield
Sep 25, 2018Iron Contributor
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 !!
Charles Boisseau
Nov 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_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?- Alan UmanosMay 15, 2020
Microsoft
MattStOnge The error you're seeing is expected. Anytime you open an Office file from SharePoint (any version, SharePoint 2010, 2013, 2016, 2019, Online, etc) using Office (2010, 2013, 2016, 2019, 365 Pro Plus, Office for Mac, etc), you are guaranteed to set a file lock. That's how the product works.
There are two types of locks that can be set, and Exclusive file lock, and a Co-authoring file lock. Which lock type is set is dependent on a few key factors. When opening Office files, SharePoint will always attempt to set a co-authoring lock first. If a co-authoring lock cannot be set, SharePoint falls back to an exclusive file lock.
Exclusive file locks act exactly as their name implies. User opens the file, because of certain factors (addressed below), an exclusive file lock is set by the user's session in SharePoint. As long as that lock is in place only the user who set the lock can edit the file. If the user saves the file when they're done and properly exits the file (doesn't put the PC in sleep mode with the file open, doesn't just close the laptop lid and walk away, doesn't leave the file open for hours on end, and instead either uses file > Close, or waits for the file to completely save, then closes out of the client), then Office can send the proper network traffic to indicate it's done with the file and SharePoint will release the lock. This is known as exiting gracefully from the file, and applies to both file lock types.
Co-Authoring file locks are applied when the file is in a state that allows co-authoring and if the user is in a client that supports co-authoring. Whenever a file is opened in Office Web Apps, Office Online Server, or Office for the web, where the file can be edited in the browser, a Co-authoring file lock will always be set.
Certain Office clients (installed on your Windows or Mac machines) do not fully support Co-Authoring. For example, Co-Authoring in Excel is only supported on Office 365 Pro Plus version 1808 and newer. All other Office desktop clients do not allow for Excel co-authoring, and will always try to set an exclusive file lock.
Outside of the Office clients, there are other factors specific to the file and where the files stored that determine what file lock type is set. For example, all of the following to cause only Exclusive file locks to be set:
- The SharePoint library where the files are stored has "Checked required for editing" enabled. Even if opened in the browser, only exclusive file locks can be set for files within such a document library.
- IRM controls on the SharePoint library or the file.
- Setting the registry key "fsshttpoff" to a value of 1 (this is NEVER recommended)
- Turning off the OneDrive Sync client "Use Office applications to sync Office files that I open" setting (this should be left 'On' by default).
- Using the legacy Office file formats (*.doc, *.xls, *.ppt) instead of the current XML based file formats (*.xlsx, *.docx, *.pptx)
- Syncing files with the old and deprecated groove.exe OneDrive for Business sync client.
- And a few other, rarer factors.
MattStOnge, for you, it sounds like other users have set a co-authoring lock on the file, but your machine can only set exclusive file locks. Since the file is Excel, check that your Office client actually supports Excel Co-authoring. If you're not on the Office 365 Pro Plus client on any of the current update channel builds (1902, 1908, 2002, 2003, 2004) then you're never expected to be able to edit the Excel file in the excel client app in near real time with your colleagues. I would compare what version of Office you're using with that of your colleagues. If it's the same version, then your machine has another factor at play preventing you from joining the Excel file's Co-authoring session.
This functionality is more than just SharePoint or Office, there is a lot more in play. What settings are set in the SharePoint Document library, on the file itself, in the Office client, on your windows/mac machine, what group policy settings are set (if your local user account and machine are domain managed), all of these matter and can affect what type of file lock your Office client can set, and by direct relation, what can be done with said file.
- 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()}
=============
- carlSteffenJul 22, 2019Copper Contributor
Potential work-around - I had this issue specifically with a PowerPoint file - I simply opened the slide show again via PowerPoint (the same way I had it open before) then rather than just closing PowerPoint with the "X" - I used the File Menu and selected "Close" - this closes the slide show and leaves PowerPoint open. as soon as I did this, the lock was released.
- Alan UmanosJul 30, 2019
Microsoft
Glad to hear that worked. That's not a workaround however, that's how the product works.
When you close out of a file stored in SharePoint , Exiting the file gracefully (File > Close, Red 'x', etc.) your machine sends information back to SharePoint telling SharePoint that you're done with the file and the lock can be released. Once SharePoint receives that Trigger, it releases the file's lock.
File locks will always happen when opening files from SharePoint, that is 100% how the product works. Where issues can be seen is releasing the lock states. If you're not co-authoring, (whether this is disabled for you somehow or if your Office client doesn't support it), then you'll set an exclusive file lock. This means only the user who opened the file from SharePoint (The user who sets the lock state) will be able to edit the file.
Unless the user exits the file gracefully, or the lock expires, no one else can edit the file. If the user does not exit from the file gracefully (Application crashed, unexpected Power Reset, etc), then the lock will be released via an expiration setting built into SharePoint. If the lock state doesn't expire, the user can re-open the file and exit gracefully to try and remove the lock.
If you're seeing the file lock does not release after a user exits gracefully from the file, you could be looking at an issue with SharePoint, your local machine, or your Office client. More often than not, these lock issues aren't actually bugs or errors and come down to understanding how these products work and how the Office files are being opened or used.
- CiaoleiMay 22, 2019Copper Contributor
David DeKeizer that worked for SP2016 on-prem as well. Thank you so much!!
- 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.