File is locked - how to unlock


For anyone having issues with files getting lock while using redis on nextcloud pi. Specially while syncing nodejs apps…

  1. Connect to your redis
    sudo redis-cli -s /var/run/redis/redis.sock
  2. authenticate in your redis with the password for redis found in /var/www/nextcloud/config/config.php
    $> auth “yourpasswordfoundinconfig.php”
    $> flushall
    Your locked files should synchronize now

This error/bug has been driving me crazy. Because there was so much variety in the user posts, I created a more standardized testing environment and replicated the bug with a standardized dataset on clean new installs using both postgres & mysql. In the process I created a one-run install script that requires minimal configuration/expertise to use. Doing the file/redis maintenance options are not actually solutions if the bug is evident on clean installs (they merely temporize the issue). Any recommendations on where to look (e.g. in nextcloud codebase) to get this bug fixed would be appreciated!

I want to see nextcloud succeed, and for it to do so this issue needs fixing!

Install script/writeup:
For freenas users (script not as good, worse deadlock errors):

1 Like

I had the same problem and I solved this by updating values on table oc_file_locks. I found some values diferent from 0 like 1 and -1. Alter this and be happy.


That part for me didn’t work. I closed my nextcloud docker to avoid any changes. Then manually deleted the files I needed and yes. The container changed the permissions for the files creating that situation. After I moved everything manually then the problem disappeared of course.


I followed the above post and it worked perfectly.


I had to set up a new nextcloud and had the same error.

I don’t use redis but memcached.
I commented out the entry for memcached in

#‘memcache.local’ => ‘\OC\Memcache\APCu’,

Now the sync works properly


solved the issue for me, thanks.

  1. sudo -u www-data php occ maintenance:mode --on
    (in Nextcloud folder)
  2. sudo redis-cli -s /var/run/redis/redis.sock
  3. flushall (OK was response)
  4. exit
  5. sudo -u www-data php occ maintenance:mode --off
    (in Nextcloud folder)
  6. sudo -u www-data php occ files:scan --all
    (in Nextcloud folder)

But there was no password in redis? Is this right?

1 Like

Thanks for pedropt laying this out so clearly. Fixed me up good!


It works for me, thanks a lot!


Just had to do this for a folder on my install. Thanks, tflidd!