# Incident note: Nextcloud "file is locked" (423 Locked): fix

> Nextcloud says “file is locked” or 423 Locked? Usually a stale lock after an aborted upload. How to check Redis locking and cron and clear old locks.

Author: Daniele Michelin · Published: 2026-11-08 · Updated: 2026-11-27 · Language: en
Canonical: https://daniele-michelin.com/en/blog/incident-note-nextcloud-423-locked/

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.

## Read the signal

Start with the exact wording of the error and its timestamp in the log. Then narrow down the cause before changing anything.

```
OCP\Lock\LockedException: "files/9a3c1e7d/Dokumente/Bericht.docx" is locked, existing lock on file: exclusive
```

## Narrow down possible 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 before changing anything

- 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 and test again

- Use Redis for locking: `'memcache.locking' => '\OC\Memcache\Redis'` in `config.php`.
- Switch background jobs to system cron: `*/5 * * * * php -f /var/www/nextcloud/cron.php` in 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.
Then repeat the original action and compare the result with the initial error.

## Keep a note for the next ticket

Record the exact error, the check result, the change and the retest. That gives the team a useful starting point next time.

## Can I just disable file locking?
Technically yes (`filelocking.enabled` set to false), but you risk corrupted files on concurrent access. Use Redis instead.

[Full error guide: Nextcloud: "file is locked" and HTTP 423 Locked](https://daniele-michelin.com/en/errors/nextcloud-file-is-locked-423/)

## Frequently asked questions

### What does “File is locked” (423) mean in Nextcloud?

A stale lock is sitting on the file. Common causes are an aborted upload or sync, a PHP process ended by a timeout, a file still open in Collabora or OnlyOffice, or file locking running through the database instead of Redis.

### How do I fix “File is locked” for good?

Set up Redis as the locking backend (`'memcache.locking' => '\OC\Memcache\Redis'` in `config.php`) and switch background jobs to system cron. Orphaned database locks can be deleted from the `oc_file_locks` table while maintenance mode is on.

### Can I just turn file locking off?

Technically yes (`filelocking.enabled` set to false), but then simultaneous access can corrupt files. Redis is the better answer.
