Nextcloud refuses access because a lock still exists for the file in transactional file locking – usually a stale lock after an aborted upload or crash.
Common 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.
How to check it
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;'
What actually helps
- 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.
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.
Full page with every command and the German/Italian version: daniele-michelin.com/en/errors/nextcloud-file-is-locked-423/
First published at daniele-michelin.com. The error lexicon covers HTTP, DNS, TLS, mail, database, PHP, nginx, systemd and Nextcloud, in German, English and Italian.
Top comments (0)