Nextcloud Text and Office lock a file during online editing, and occ can clear a lock that a crashed browser or dropped session leaves behind. An administrator can unlock a stale Text or Office file lock after stopping the editor and confirming the file ID and Files Lock app support, which removes the Locked by editing online in Text label and lets the file be renamed or saved again.

The Files Lock app stores these locks, and it decides whether occ has a files:lock command at all. Nextcloud 34 and later ship the app enabled, while older servers have it only when it was added from the App Store. The editing app normally releases its lock when the session closes, but an app-owned lock has no expiry by default, so one abandoned by a lost session can stay until it is removed.

Transactional file locking is a separate layer that holds short locks in the database or Redis while a file is being read or written. files:lock neither shows nor clears those locks, and expired ones clear on their own after filelocking.ttl, one hour by default. A file reported as not locked that still fails with LockedException belongs to that layer.

Steps to unlock a file locked by an app in Nextcloud:

  1. Open the Actions menu for the file in Nextcloud Files to read the lock label.

    The label names the app that holds the lock. The file owner also sees Unlock file in this menu, and it releases the same lock once the editor has stopped. A share recipient sees no unlock item, so that person needs an administrator and occ.

  2. Close the file on every device that still has it open.

    Do not unlock a file that is still uploading, open in an editor, or syncing from another device. Removing an active lock can let two writers change the same file at the same time.

  3. Find the file ID from the Nextcloud web root.
    $ sudo -E -u www-data php occ info:file /ada/files/report.md
    report.md
      fileid: 99
      mimetype: text/markdown
      modified: November 6, 2026, 2:41:47 PM UTC
      size: 47 B
      etag: 6aede76b95015
      permissions: full permissions
    
    The following users have access to the file
    
    ada:
      /ada/files/report.md: full permissions
        home storage
    bob:
      /bob/files/report.md/: read, update, share
        shared by ada owned by ada

    The path starts with the user ID and the files folder, because /ada/report.md returns file /ada/report.md not found. The same ID appears in the address of the open file, such as /apps/files/files/99. On packaged installs with a different web user, web root, or wrapper, keep the same occ command shape and replace www-data or php occ with the local values.

  4. Check which owner holds the lock on that file ID.
    $ sudo -E -u www-data php occ files:lock --status 99
    File #99 is locked by text
     - Locked at: 2026-11-06T14:42:51+00:00

    The owner text is Nextcloud Text and richdocuments is Nextcloud Office, while a user ID marks a lock set by a person or client. If the command reports File #99 is not locked while uploads or WebDAV requests still fail with LockedException messages, inspect the Nextcloud log and the configured locking cache instead of clearing database rows manually. The reply Command "files:lock" is not defined means the Files Lock app (files_lock, listed as Temporary files lock) is disabled or not installed. Nextcloud does not enforce Text or Office locks without the app, so a file that still fails usually points to a transactional lock, and enabling the app again restores any lock it had stored.
    Related: How to view Nextcloud logs
    Related: How to configure Redis caching for Nextcloud

  5. Unlock the stale file ID with a user ID that has access to the file.
    $ sudo -E -u www-data php occ files:lock --unlock 99 ada
    Unlocked file #99

    Unlocking a neighboring ID can affect another user's file when shared folders or group folders expose similar names, so the ID must come from info:file.

    Any user listed under The following users have access to the file works. An app-owned lock stays in place when the user ID is left out, which ends in a TypeError, or when that user cannot reach the file, which ends in a NotFoundException. Nextcloud 34 and older print unlocking File #99 instead of the line shown.

  6. Recheck the lock status for the same file ID.
    $ sudo -E -u www-data php occ files:lock --status 99
    File #99 is not locked
  7. Retry the action that failed in Nextcloud Files.

    The original rename, save, or sync now goes through, and the Actions menu no longer shows Locked by editing online in Text. If the same file locks again immediately, leave the file locked and investigate the writer that is recreating the lock, such as an Office session, sync client, WebDAV mount, external storage backend, or Redis locking cache.

Share this guide