What the message looks like
OCP\Lock\LockedException: "files/9a3c1e7d/Dokumente/Bericht.docx" is locked, existing lock on file: exclusiveCommon causes
- File locking uses the database instead of Redis, and locks stay behind after aborts.
- An aborted upload or desktop client sync; the PHP process was killed by a timeout.
- The file is still open in Collabora or OnlyOffice.
- Background jobs do not run (no system cron), so expired locks are not cleaned up.
Check
- Which locking backend is configured?
sudo -u www-data php /var/www/nextcloud/occ config:system:get memcache.locking - Check that Redis is reachable
redis-cli ping - Count locks in the database (with DB locking)
mysql -u nextcloud -p nextcloud -e 'SELECT COUNT(*) FROM oc_file_locks WHERE `lock` <> 0;' - Check the background job mode
sudo -u www-data php /var/www/nextcloud/occ config:app:get core backgroundjobs_mode
Fix
- Use Redis for locking:
'memcache.locking' => '\OC\Memcache\Redis'inconfig.php. - Switch background jobs to system cron:
*/5 * * * * php -f /var/www/nextcloud/cron.phpin www-data's crontab. - Clear stale DB locks: maintenance mode on,
DELETE FROM oc_file_locks WHERE 1;, maintenance mode off. - With Redis, locks expire via TTL; only flush the Redis database in an emergency, and only if Nextcloud is its sole user.
- If needed, run
occ files:scan --path="user/files/folder"for the affected path afterwards.
Typical scenario
A colleague edits a .docx in Collabora and the browser crashes. The next day the file can neither be renamed nor deleted; Nextcloud reports '423 Locked' and the log shows a LockedException with 'existing lock on file: exclusive'. First check in config.php where the locks live: with memcache.locking on Redis they have a lifetime, without Redis they sit in the database table oc_file_locks.
FAQ
Can I just disable file locking?
Technically yes (filelocking.enabled set to false), but you risk corrupted files on concurrent access. Use Redis instead.
Why does the desktop client keep hitting this?
Usually large files plus short PHP timeouts: the upload aborts and the lock stays. Raise the timeouts and use Redis locking.
How long does a stale lock last?
By default locks expire after one hour (filelocking.ttl, 3600 seconds). With database locking, the cron job clears expired entries. If cron does not run, they linger unnecessarily long.
May I delete locks by hand?
Only if you are sure no process still accesses the file, such as a running upload or an open Collabora session. Otherwise you risk inconsistent files. When in doubt, wait for the expiry.
Is this the same as the lock from the 'Files Lock' app?
No. Transactional locks protect short-running operations, whereas the app locks files deliberately for other users. You see the latter with the locker's name in the interface and can release it there.