Can't delete file locally and in Nextcloud web-interface - file is present on database and remote on disk

The Basics

  • Nextcloud Server version (e.g., 29.x.x):

    • 29.0.10
  • Operating system and version (e.g., Ubuntu 24.04):

    • Shared Hosting Netcup Linux 5.10.0-32-amd64 x86_64
  • Web server and version (e.g, Apache 2.4.25):

    • Apache ???
    • memory_limit 512M
    • max_execution_time 180
    • max_input_time 60 (Standard)
    • post_max_size 128M
    • upload_max_filesize 128M
    • opcache.enable on (Standard)
  • PHP version (e.g, 8.3):

    • 8.2.25
  • Is this the first time you’ve seen this error? (Yes / No):

    • No
  • When did this problem seem to first start?

    • a couple of months ago -
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)

  • Are you using CloudfIare, mod_security, or similar? (Yes / No)

    • no

Summary of the issue you are facing:

I want to delete a file on the Nextcloud web-userinterface , but I can’t, it says >“Delete file” action failed<. I already run
files:scan --all
files:cleanup
files:repair-tree

I deleted the oc_file_locks table in my database like described here:

The file exists as physical file on the server when I acces my files via FTP but there it has a file size of 113Mb where as synced on my PC locally it only has 0kb. On the Webuser-Interface on Nextcloud it has 113Mb but I can’t access any info on it, it says >“Open details” action failed<.

When I delete the file locally it’s re-downloaded after a while. Like I mentioned I can’t delete the file on the Nextcloud webinterface.

Now, what should I do? Can I delete the file via FTP from the server? Or delete the entry from the database?

The Sync-Client-Log gives a “403 Forbidden” error, when trying to download that file.

2025-01-13 23:20:57:829 [ warning nextcloud.sync.propagator C:\Users\User\AppData\Local\Temp\windows-27802\client-building\desktop\src\libsync\owncloudpropagator.cpp:288 ]: Could not complete propagation of “Steinberg_Download_Assistant_1.35.0_Installer_win.exe” by OCC::PropagateDownloadFile(0x24258431930) with status OCC::SyncFileItem::BlacklistedError and error: “Server hat "403 Forbidden" auf "GET XXX/o/remote.php/dav/files/admin_owncloud_Ba3RMRVvL82di9r/Steinberg_Download_Assistant_1.35.0_Installer_win.exe" geantwortet”

2025-01-13 23:20:57:829 [ warning nextcloud.sync.credentials.webflow C:\Users\User\AppData\Local\Temp\windows-27802\client-building\desktop\src\gui\creds\webflowcredentials.cpp:208 ]: “Error transferring https://XXX/o/remote.php/dav/files/admin_owncloud_Ba3RMRVvL82di9r/Steinberg_Download_Assistant_1.35.0_Installer_win.exe - server replied: Forbidden”

Steps to replicate it (hint: details matter!):

I don’t know how this happened, I never played with the files in the Nextcloud data-directory via FTP. I guess there was an error uploading or syncing.

Nextcloud

The output of occ config:list system or similar is best, but, if not possible, the contents of your config.php file from /path/to/nextcloud is fine (make sure to remove any identifiable information!):

{
“system”: {
“instanceid”: “REMOVED SENSITIVE VALUE”,
“passwordsalt”: “REMOVED SENSITIVE VALUE”,
“secret”: “REMOVED SENSITIVE VALUE”,
“trusted_domains”: [
www.XXX.de”,
cloud.XXX.de
],
“datadirectory”: “REMOVED SENSITIVE VALUE”,
“dbtype”: “mysql”,
“version”: “29.0.10.1”,
“overwrite.cli.url”: “https://www.XXX.de/o”,
“dbname”: “REMOVED SENSITIVE VALUE”,
“dbhost”: “REMOVED SENSITIVE VALUE”,
“dbport”: “”,
“dbtableprefix”: “oc_”,
“mysql.utf8mb4”: true,
“dbuser”: “REMOVED SENSITIVE VALUE”,
“dbpassword”: “REMOVED SENSITIVE VALUE”,
“installed”: true,
“theme”: “”,
“loglevel”: 2,
“trashbin_retention_obligation”: “15, auto”,
“app_install_overwrite”: [
“occweb”
],
“encryption.legacy_format_support”: false,
“encryption.key_storage_migrated”: false,
“default_phone_region”: “DE”,
“mail_smtpmode”: “smtp”,
“mail_smtpsecure”: “tls”,
“mail_sendmailmode”: “smtp”,
“mail_from_address”: “REMOVED SENSITIVE VALUE”,
“mail_domain”: “REMOVED SENSITIVE VALUE”,
“mail_smtpauthtype”: “LOGIN”,
“mail_smtpauth”: 1,
“mail_smtphost”: “REMOVED SENSITIVE VALUE”,
“mail_smtpname”: “REMOVED SENSITIVE VALUE”,
“mail_smtppassword”: “REMOVED SENSITIVE VALUE”,
“maintenance_window_start”: 1,
“preview_max_x”: 1024,
“preview_max_y”: 1024,
“maintenance”: false,
“updater.release.channel”: “stable”
}
}

Hi msg_01,

I won’t be able to help you out, but can tell you something that I found after related trouble. It was years back, but I think the mechanism has remained the same.

For remote storage, the file itself stays remote. When accessing such a file though, Nextcloud will cache it in the database. It is now ‘some kind of local’, but it is a (large) entry in the database, not a file as such.

occ files:scan will scan Nextcloud’s data directories, not remote storage, to update/sync the database.

Are you somewhat familiar with SQL? If so, you could try finding the record for this remote file in the table oc_filecache and delete it manually. Warnings apply. Perhaps another forum member can suggest a better option!

PS: to increase your chances of getting help: don’t make it difficult for knowledgeable people to read your post. There is a lot of text that seems default (but not answered, all the “paste here”) template.

Please check your Nextcloud log. It should have hints about why this part is occurring.

OCC::SyncFileItem::BlacklistedError and error: “Server hat “403 Forbidden” auf "GET XXX/o/remote.php/dav/files/admin_owncloud_Ba3RMRVvL82di9r/Steinberg_Download_Assistant_1.35.0_Installer_win.exe

Are you forbidding any file types/names/extensions on either the client-side or server-side?

Hello wbk, thank you so much for your advice, I already edited my request. It’s my first time here, so thank you!
I can access the database but is it really save to delete the record of the file from there?

What do you mean by remote storage? I have my domain and webspace on a shared hoster and there I installed Nextcloud. All files are stored there on my webspace. I don’t connect from there to another cloud service like Dropbox etc.

Thank you for your help.

I increased the log-level to 0 in config.php
Now, which log you mean? When I go to XXX/index.php/settings/admin/logging there doesn’t seem to be anything related to my action trying to delete the file. Just this, but I think it’s not related:

Exception dirty table reads: SELECT * FROM *PREFIX*jobs WHERE (reserved_at <= :dcValue1) AND (last_checked <= :dcValue2) AND (time_sensitive = :dcValue3) ORDER BY last_checked ASC LIMIT 1

Are you forbidding any file types/names/extensions on either the client-side or server-side?
No, no that I know of…

I discovered that there are more files, that are present remotely on my webspace/Nextcloud when accessed via Web-Interface and not present on my laptop locally (client log gives again 403 error). When I try to delete these files remotely via Web-Interface there’s the same error.

Is this maybe related to these issues here, where there are orphaned entries? I couldn’t really understand the solution:

Thanks!

Let’s try this a different way:

  • Post your config as requested in the support template :wink: - i.e. output of occ config:list system
  • Set your log level to something reasonable for now (2 is the default; 0 is way too noisy unless we really end up in the weeds troubleshooting something).
  • See what log entries pop up in your Nextcloud log while reproducing the problem

The 403 Forbidden is coming from somewhere. The transaction is being blocked server-side for something likely related to a forbidden filename, anti-virus scanner, or any number of other ways to block files/connections.

Ideally also check your web server error log, since it’s possible something else weird is going on such as filtering at your web server level outside of Nextcloud.

Hi msg_01

I must have gotten distracted by “remote” in the thread title. “Remote storage” is functionality of Nextcloud to make files available that are not in Nextcloud, and seems not to be of concern in your case. Sorry for the noise :wink:

edit to add:

Seeing ‘shared hosting’ (not VPS): do you have full control over your server? I’m not too familiar with installation options; ‘Webinstall’, is that GitHub - nextcloud/web-installer: 💊 The web installer for Nextcloud ?

Yes, I am on a shared hoster (Netcup) and don’t have full access to the server, so no VPS. Yes, I used the Web-installer from the Nextcloud homepage - now it’s a little hidden under “Community Projects”.

Post your config as requested in the support template :wink: - i.e. output of occ config:list system

Sorry, added this info above in my initial post.

Set your log level to something reasonable for now (2 is the default; 0 is way too noisy unless we really end up in the weeds troubleshooting something).
See what log entries pop up in your Nextcloud log while reproducing the problem.

Did that, unfortunately no log entries here: XXX/index.php/settings/admin/logging or shall I look elsewhere?

The 403 Forbidden is coming from somewhere. The transaction is being blocked server-side for something likely related to a forbidden filename, anti-virus scanner, or any number of other ways to block files/connections.
Ideally also check your web server error log, since it’s possible something else weird is going on such as filtering at your web server level outside of Nextcloud.

If it is a filtering issue, shouldn’t the same file types always be blocked? I have the problem with various file-types: *.log, *.exe, *.cmd, *.psd

What I found out right now: The error goes away, if I delete the directory in which the file is located. Unfortunately, I can’t do that with the root directory.

Doesn’t the 403 perhaps mean that the files are in the database, but not actually physically on the server? It it advisable to delete the file-entries from the database via PHPMyAdmin / SQL?

Unfortunately, I also keep getting error messages that my server memory is insufficient, perhaps the shared hosting is simply undersized? Is there anything I can do here to make Nextcloud less resource-hungry or do I need to upgrade my shared hosting?

[PHP] Error: Allowed memory size of 536870912 bytes exhausted (tried to allocate 100667392 bytes) at /var/www/vhosts/XXXXXX/lib/public/AppFramework/Http/JSONResponse.php#71
GET /XXXXX/index.php/apps/logreader/api/poll?lastReqId=groUcfWgbvVdJXdNCMwn
from 2a02:3100:1de2:6000:31bc:4536:4aaa:6d9b by XXXXXXXX at 16.01.2025, 11:50:54

most probably, ask the service provider

Disable file locking in Nextcloud config file

One way to fix the file is locked error is to disable the file locking feature in Nextcloud. This feature is meant to prevent concurrent access and conflicts on files, but it can also cause problems if the locks are not released properly. To disable file locking, you need to edit the Nextcloud config file.

  • edit config.php line that says 'filelocking.enabled' => true, and change it to 'filelocking.enabled' => false,

This will disable the file locking feature in Nextcloud and you should be able to edit or delete your files without any error.

see also How to fix: File is locked error?

I assume, that the permissions of the file in the file system of the server may be wrong, that neither read nor write/delete is possible (f.ex. root root instead of www-data www-data).

Can I change the permission of the file via FTP or will this break anything? What would be the right permission? Thank you!

Thank you, I will try that. I already deleted all file-locks in the Database, that didn’t help. As I am accessing my Nextcloud from two computers sometimes, file locking isn’t a bad idea…

I looked via FTP: Permissions were ok.

I got rid of the problem by deleting the files that were not synchronizing via FTP on the server. Not a good or permanent solution, I am afraid that this problem will come back. I suspect that my shared hosting can’t cope when I upload serveral files at once. Is there any way to reduce the impact of Nextcloud on the shared hosting? I have only a couple of essentials apps installed, nothing fancy.

It would be the amount of processors on the shared hosting so the process of uploading is not finished. Try to set the max execution time to 900 sec. And perhaps you should set the maxpost size to 1GB.

I just looked here in the Nextcloud PHP Serverinfo and found the info, that the max execution time seems to be 900 sec:

Version: 8.2.25

Memory limit: 512 MB

Max execution time: 3600

Upload max size: 128 MB

OPcache Revalidate Frequency: 2

Extensions: Core, date, libxml, openssl, pcre, zlib, bcmath, bz2, calendar, ctype, dba, dom, hash, fileinfo, filter, ftp, gettext, gmp, json, iconv, SPL, session, mbstring, pcntl, standard, exif, Phar, posix, random, readline, Reflection, imap, shmop, SimpleXML, soap, sockets, sysvmsg, sysvsem, sysvshm, tokenizer, xml, xmlreader, xmlwriter, zip, mysqlnd, cgi-fcgi, imagick, curl, gd, mysqli, PDO, pdo_mysql, xsl, sqlite3, intl, sodium, ldap, tidy, pdo_pgsql, pdo_sqlite, igbinary, redis, ionCube Loader, Zend OPcache

i think you check permission for this file. check rule in flows (Files access control).

Hm, I already checked the file’s permissions via FTP, nothing unusual… I think my server is just not “strong” enough for Nextcloud and then things get mixed up…

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.