File is locked - how to unlock

Since it has been up to 39 months since the quoted users have submitted a post on this topic, I believe that it is necessary to ask for an update: has anyone experienced any problems as a result of disabling file lock? The admin is making a cautious decision regarding the file lock configuration on an installation with one user on Notes, Calendar, and Deck at a time. Please provide the version numbers in your reply to provide readers a more informed decision.

Is it written like this? ?
‘Filelocking.enabled’ => false
After I add it, my php can’t be used directly

Hello all! I have a question.

The usual solution given to wipe stale locks is the following:

  1. DELETE all the rows from oc_file_locks
  2. Run occ files:scan --all

I am thus wondering why it would not be reasonable to set lock to 0 on all non-zero rows, like this :

UPDATE `oc_file_locks` 
SET `oc_file_locks`.`lock` = 0
WHERE `oc_file_locks`.`lock` != 0;

Would that be asking for trouble? (given maintenance mode is enabled, of course)


DELETE FROM oc_file_locks WHERE 1

results in:

ERROR: argument of WHERE must be type boolean, not type integer LINE 1: DELETE FROM oc_file_locks WHERE 1

modify the command:

DELETE FROM oc_file_locks WHERE true

1 Like

My site is hosted on Cloudways. This automatically installs the Varnish Cache which turns out not to work with nextcloud. Turning off Varnish in the Cloudways settings resolved this for me.

I am experiencing issues with locked files that I cannot delete or move, but I have a subscription with a provider and thus have no admin access. Is there really no end-user-accessible way to escape from this situation? If so, any chance at getting one added?

I’m having similar problems. First of all, I have to say my head is spinning a bit from looking at these help pages because I am a total novice when it comes to coding and stuff like that. I didn’t think I’d have to know such things when I left Google Drive for NextCloud.

I’m having problems moving folders. I keep getting messages that say “could not move” and sometimes “target exists.”

Can someone help me figure this out in simple English?

Thank you so much!

I have exactly the same problem.
Moreover, when synchronizing a large file, somewhere around 180GB through the Nextcloud client. Error message 423 Locked appears, and after a while everything starts to synchronize all over again. In the log I see the following error "Error PHP Error: fopen (/ var / nextcloud / uploads / 1939388670/00000839): failed to open stream: No such file or directory at / var / www / nextcloud / lib / private / Files / Storage / Local.php # 354 "
What to do with it? in php.ini the maximum time is 10400.

1 Like

Make sense…

" Empty table oc_file_locks"
Oh ok. It’s nice if you wrote how to do it, because it’s not written anywhere …
One problem generates another. Opensource world.

Please be respectful. The description of how to perform exactly this action is described in detail by @tflidd in the post you are quoting from.

Do you think if that was a solution, I would still be writing here?

Yes I do think that this is the solution:


Another temporary solution is to set filelocking to false in your config.php:
'filelocking.enabled' => false,

On Nextcloud 21 in a docker container you would need this command:

docker exec nextyourdomain_db_1 mysql nextcloud -p$MYSQL_ROOT_PASSWORD -e "SELECT * FROM oc_file_locks WHERE \`lock\`<>0;"


we had the same issue several times already but the solutions described so far cannot be applied: the lock table is empty, so the SQL statements will not work. Disabling filelocking is not a solution for us.

We came up with a different solution which workes just fine:

  • Log on as with an admin account via ssh
  • Go to the directory where the file should be, check for any partially uploaded files and delete them
  • Upload the file via scp and move it to the destination directory
  • Change owner and group to www-data
  • run occ files: scan


1 Like

Thank you for this useful post!

It’s now nearly 6 years later, yet here we are, the bug still persists, this is ridiculous… Just give us a gui option for admins to unlock the files


If it helps, I “solved” this problem as follows: I can't rename files...(Não consigo renomear arquivos) Help me please!

To the point!
Thank you.