What is a locked file?

nextcloudOccasionally you might have a file that doesn't sync properly, and subsequently can't be deleted or renamed.  The file might give an error saying that it is 'locked'.  This article describes the procedure for unlocking files.

Checking the log

You might start by looking at the log, to see if any locked files are reported.

  1. Log into your Nextcloud instance with an admin account.
  2. Go to the Cog > Admin.
  3. Select Logging in the left pane.

You will see Fatal logs reporting any files that are locked.


Deleting locks from the database

Start by putting your Nextcloud instance into Maintenance mode.

  1. Access your database using phpMyAdmin.
  2. Truncate or empty the oc_file_locks.
  3. Alternatively run the following SQL code
DELETE FROM oc_file_locks WHERE 1

Now you can disable Maintenance mode, and all being well you will be able to delete and/or edit the locked file.


Permanent option

If you find that files are being regularly locked, you might want to stop file locking altogether.  This is not recommended, and is only added here for information.

  1. Open the /config/config.php file for editing.
  2. Add the following line and Save the file.
'filelocking.enabled' => false,


Thanks for visiting.