Occ files:scan-app-data gets stuck and provides no output

Support intro

Sorry to hear you’re facing problems. :slightly_frowning_face:

The community help forum (help.nextcloud.com) is for home and non-enterprise users. Support is provided by other community members on a best effort / “as available” basis. All of those responding are volunteering their time to help you.

If you’re using Nextcloud in a business/critical setting, paid and SLA-based support services can be accessed via portal.nextcloud.com where Nextcloud engineers can help ensure your business keeps running smoothly.

Getting help

In order to help you as efficiently (and quickly!) as possible, please fill in as much of the below requested information as you can.

Before clicking submit: Please check if your query is already addressed via the following resources:

(Utilizing these existing resources is typically faster. It also helps reduce the load on our generous volunteers while elevating the signal to noise ratio of the forums otherwise arising from the same queries being posted repeatedly).

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can. :heart:

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • 33.0.2
  • Operating system and version (e.g., Ubuntu 24.04):
    • Ubuntu 24.04
  • Web server and version (e.g, Apache 2.4.25):
    • Apache 2.4.62
  • PHP version (e.g, 8.3):
    • 8.4
  • Is this the first time you’ve seen this error? (Yes / No):
    • Yes
  • When did this problem seem to first start?
    • NC 33.x
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • Bare Metal
  • Are you using CloudfIare, mod_security, or similar? (Yes / No)
    • No

Summary of the issue you are facing:

The command

occ files:scan-app-data -v

is slow, provides no output and does not return.
The command cannot be interrupted with CTRL+C

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

After upgrading to NC 33.x, I have executed

occ preview:cleanup
occ preview:generate-all

to migrate all previews to the new architecture.
However, after all previews have been regenerated, I saw errors like

[index] Fehler: Unable to open preview stream at <nc-path>/appdata_oca547gxxkcm/preview/5/d/c/e/f/3/9/12431/256-455.jpg
	GET /index.php/core/preview?fileId=12431&x=256&y=256&a=1&mode=cover&forceIcon=0
	von 192.168.178.34 von <user> um 04.04.2026, 11:58:02

So I thought that rescanning app data would fix this issue. So, I execute

occ files:scan-app-data

Which prints

Scanning AppData for files

and then nothing else. I cannot interrupt the command with CTRL+C. It is like the terminal window is stuck.

I have run this command in a background process for over 3 days and it did not finish. I saw mariadb taking ~25-50% CPU load the whole time with some gs (ghostscript?) every now and then.

I have enabled slow queries log in MariaDB, but there is nothing in the log.
There is also nothing the normal MariaDB Log

Log entries

Nextcloud

Please provide the log entries from your Nextcloud log that are generated during the time of problem (via the Copy raw option from Administration settings->Logging screen or from your nextcloud.log located in your data directory). Feel free to use a pastebin/gist service if necessary.

None

Configuration

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": {
        "serverid": 0,
        "default_phone_region": "DE",
        "onlyoffice": {
            "editors_check_interval": 0,
            "verify_peer_off": true,
            "jwt_header": "AuthorizationJwt",
            "jwt_secret": "***REMOVED SENSITIVE VALUE***"
        },
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "forwarded_for_headers": [
            "HTTP_X_FORWARDED"
        ],
        "trusted_proxies": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "192.168.178.3",
            "***REMOVED SENSITIVE VALUE***",
            "127.0.0.1",
            "***REMOVED SENSITIVE VALUE***",
            "***REMOVED SENSITIVE VALUE***"
        ],
        "allowed_admin_ranges": [
            "192.168.0.0\/16"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "dbtype": "mysql",
        "version": "33.0.2.2",
        "overwrite.cli.url": "***REMOVED SENSITIVE VALUE***",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "mail_smtpmode": "smtp",
        "mail_sendmailmode": "smtp",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "587",
        "mail_smtpauth": true,
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***",
        "mail_from_address": "***REMOVED SENSITIVE VALUE***",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.distributed": "\\OC\\Memcache\\Redis",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0
        },
        "enabledPreviewProviders": [
            "OC\\Preview\\PNG",
            "OC\\Preview\\JPEG",
            "OC\\Preview\\GIF",
            "OC\\Preview\\HEIC",
            "OC\\Preview\\BMP",
            "OC\\Preview\\MP3",
            "OC\\Preview\\TXT",
            "OC\\Preview\\PDF",
            "OC\\Preview\\MP4",
            "OC\\Preview\\MarkDown",
            "OC\\Preview\\MOV",
            "OC\\Preview\\Image",
            "OC\\Preview\\TIFF",
            "OC\\Preview\\Movie"
        ],
        "preview_max_x": 2560,
        "preview_max_y": 1440,
        "jpeg_quality": 90,
        "maintenance": false,
        "data-fingerprint": "30b96630ec3d1182ae55146a72cb7777",
        "theme": "",
        "htaccess.RewriteBase": "\/",
        "loglevel": 2,
        "updater.release.channel": "stable",
        "ncd_admin_settings": {
            "disallow_aria2_settings": "0",
            "ncd_yt_binary": "",
            "ncd_aria2_binary": ""
        },
        "allow_local_remote_servers": true,
        "maintenance_window_start": "2",
        "defaultapp": "",
        "trashbin_retention_obligation": "15,30",
        "memories.exiftool": "\/var\/www\/nextcloud\/apps\/memories\/bin-ext\/exiftool-amd64-glibc",
        "memories.vod.path": "\/var\/www\/nextcloud\/apps\/memories\/bin-ext\/go-vod-amd64",
        "memories.vod.ffmpeg": "\/usr\/bin\/ffmpeg",
        "memories.vod.ffprobe": "\/usr\/bin\/ffprobe",
        "memories.gis_type": 1,
        "memories.db.triggers.fcu": true,
        "app_install_overwrite": {
            "0": "unsplash",
            "1": "co2clock",
            "3": "files_downloadactivity",
            "4": "otpmanager"
        },
        "log.condition": {
            "apps": [
                "admin_audit"
            ]
        },
        "logfile_audit": "\/media\/Samsung4TB\/nextcloud_data\/nextcloud.log",
        "music.lastfm_api_key": "***REMOVED SENSITIVE VALUE***",
        "files.chunked_upload.max_size": 5242880,
        "forbidden_filename_basenames": [
            "con",
            "prn",
            "aux",
            "nul",
            "com0",
            "com1",
            "com2",
            "com3",
            "com4",
            "com5",
            "com6",
            "com7",
            "com8",
            "com9",
            "com\u00b9",
            "com\u00b2",
            "com\u00b3",
            "lpt0",
            "lpt1",
            "lpt2",
            "lpt3",
            "lpt4",
            "lpt5",
            "lpt6",
            "lpt7",
            "lpt8",
            "lpt9",
            "lpt\u00b9",
            "lpt\u00b2",
            "lpt\u00b3"
        ],
        "forbidden_filename_characters": [
            "<",
            ">",
            ":",
            "\"",
            "|",
            "?",
            "*",
            "\\",
            "\/"
        ],
        "forbidden_filename_extensions": [
            " ",
            ".",
            ".filepart",
            ".part"
        ],
        "memories.vod.vaapi": true,
        "memories.vod.disable": false,
        "memories.vod.use_transpose": true
    }
}

Apps

The output of occ app:list (if possible).

Enabled:
  - admin_audit: 1.23.0
  - app_api: 33.0.0
  - bruteforcesettings: 6.0.0
  - calendar: 6.2.2
  - cloud_federation_api: 1.17.0
  - contacts: 8.4.3
  - dashboard: 7.13.0
  - dav: 1.36.0
  - epubviewer: 1.9.2
  - federatedfilesharing: 1.23.0
  - files: 2.5.0
  - files_antivirus: 6.2.0
  - files_pdfviewer: 6.0.0
  - files_sharing: 1.25.2
  - files_trashbin: 1.23.0
  - impersonate: 4.0.0
  - integration_paperless: 1.0.11
  - logreader: 6.0.0
  - lookup_server_connector: 1.21.0
  - memories: 8.0.1
  - music: 3.0.0
  - notes: 4.13.1
  - notifications: 6.0.0
  - notify_push: 1.3.1
  - oauth2: 1.21.0
  - onlyoffice: 10.0.0
  - otpmanager: 1.1.2
  - password_policy: 5.0.0
  - passwords: 2026.3.21
  - photos: 6.0.0
  - previewgenerator: 5.13.0
  - privacy: 5.0.0
  - profile: 1.2.0
  - provisioning_api: 1.23.0
  - recognize: 11.0.1
  - related_resources: 4.0.0
  - serverinfo: 5.0.0
  - settings: 1.16.0
  - sharebymail: 1.23.0
  - sharereview: 2.1.0
  - side_menu: 5.3.0
  - spreed: 23.0.3
  - systemtags: 1.23.0
  - tasks: 0.17.1
  - text: 7.0.0
  - theming: 2.8.0
  - theming_customcss: 1.20.0
  - twofactor_backupcodes: 1.22.0
  - twofactor_totp: 15.0.0
  - unsplash: 3.1.0
  - updatenotification: 1.23.0
  - viewer: 6.0.0
  - weather_status: 1.13.0
  - webhook_listeners: 1.5.0
  - workflow_script: 4.0.0
  - workflowengine: 2.15.0
Disabled:
  - activity: 6.0.0 (installed 2.15.0)
  - circles: 33.0.0 (installed 23.1.0)
  - comments: 1.23.0 (installed 1.14.0)
  - contactsinteraction: 1.14.1 (installed 1.6.0)
  - encryption: 2.21.0
  - federation: 1.23.0 (installed 1.14.0)
  - files_downloadlimit: 5.1.0 (installed 5.0.0-dev.0)
  - files_external: 1.25.1
  - files_reminders: 1.6.0 (installed 1.5.0)
  - files_versions: 1.26.0 (installed 1.18.0)
  - firstrunwizard: 6.0.0 (installed 2.13.0)
  - nextcloud_announcements: 5.0.0 (installed 1.16.0)
  - recommendations: 6.0.0 (installed 1.2.0)
  - support: 5.0.0 (installed 1.10.0)
  - survey_client: 5.0.0 (installed 1.10.0)
  - suspicious_login: 11.0.0 (installed 4.4.0)
  - testing: 1.23.0
  - twofactor_nextcloud_notification: 7.0.0
  - user_ldap: 1.24.0
  - user_status: 1.13.0 (installed 1.2.0)

Hi. Thanks for posting this. I have exactly the same issue. The ‘Unable to open preview stream’ error, Scanning AppData for files runs for ages, cannot be interrupted, provides no output even with -vvv added. High DB CPU load, but no disk activity.

Sadly I have no further information, but will keep looking. I hope other people read this and can provide more info or directions to investigate.

Okay, I’ve done a lot of things back-and-forth (including changing between php versions, fpm, memcache, fidling with memories app and much more), but I’m pretty confident that the sollution eventually was to

  • delete all previews from appdata***/preview folder
  • delete all preview references directly from the (mysql) db
  • then run occ preview:cleanup again and sit on my hands for a while
  • run occ files:scan-app-data
  • run occ files:scan –all

Now everything works as expected.

I will give this a try in the coming days. From which table did you delete previews? From the old location oc_filecache table?

Can you by any chance provide the sql command you have used?

Thanks!

Indeed, oc_filecache => DELETE FROM oc_filecache WHERE path LIKE 'appdata_{appid}/preview/%';

I did delete all preview files, deleted all entries from oc_filecache and did the preview:cleanup once again.

After that, files:scan and files:scan-app-data works all right.

However as soon as I generate previews again, the cmd files:scan-app-data is back to where it started. No output, cannot be interrupted, high mariadb usage.

@Castiontone Can you see the same behavior on your end?

The only difference now is that the DB is clean, oc_filecache no longer holds any previews so that does not seem to be related to the problem.

There must something wrong with how the queries are done for previews which leads to many queries during scan-app-data. I am kind fo surprised I am not able to find such issue. If anyone finds anything, please let me know!

Yes, the same behavour. However, as the previews and db have been cleaned up, the job does finishes and does not take that long anymore on my installation. Furthermore, the orignal error ‘Unable to open preview stream’ is gone now, and everyting runs smooth.

So it looks like that the job cannot be interrupted and does not give any feedback is by design.

I can confirm. I have timed the occ files:scan-app-data command and took 35 minutes in comparison to > 3 days before.

I have redirected the output into a file and I can see output and the very end before it finishes. So I guess all the output is somehow buffered and only flushed at the end to the console or the job is doing something else first which does not give any output. I dont think this is how it is supposed to be.

Anyway, it looks good now. So for anyone seeing this issue: make sure your DB no longer has any preview entries in the oc_filecache table as it looks like that this triggers some migration job in addition which leads to big runtimes