Nextcloud AIO wirte access problem with preview generator

Each time I log into my nextcloud AIO server via ssh, i get this information: You have new mail. This is the content:

root@nextcloud:~# cat /var/spool/mail/root
From root@nextcloud.localdomain  Tue Mar 24 10:40:02 2026
Return-Path: <root@nextcloud.localdomain>
X-Original-To: root
Delivered-To: root@nextcloud.localdomain
Received: by nextcloud.localdomain (Postfix, from userid 0)
	id 9199347B6A; Tue, 24 Mar 2026 10:40:02 +0000 (UTC)
From: root@nextcloud.localdomain (Cron Daemon)
To: root@nextcloud.localdomain
Subject: Cron <root@nextcloud> docker ps --format "{{.Names}}" | grep -q "^nextcloud-aio-nextcloud$" && docker exec --user www-data nextcloud-aio-nextcloud php occ preview:pre-generate
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: quoted-printable
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/root>
X-Cron-Env: <LOGNAME=root>
Message-Id: <20260324104002.9199347B6A@nextcloud.localdomain>
Date: Tue, 24 Mar 2026 10:40:02 +0000 (UTC)

Das Datenverzeichnis ist schreibgesch=C3=BCtzt.
Berechtigungen k=C3=B6nnen zumeist korrigiert werden, indem dem Webserver=
 Schreibzugriff auf das Wurzel-Verzeichnis einger=C3=A4umt wird. Siehe au=
ch https://docs.nextcloud.com/server/32/go.php?to=3Dadmin-dir_permissions=
. =


An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/html/lib/privat=
e/Console/Application.php:143
Stack trace:
#0 /var/www/html/console.php(84): OC\Console\Application->loadCommands(Ob=
ject(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component=
\Console\Output\ConsoleOutput))
#1 /var/www/html/occ(33): require_once('/var/www/html/c...')
#2 {main}

The data directory isn’t actually write-protected. And the problem – as far as I can see – only affects the preview job.

That’s my config.php:

<?php
$CONFIG = array (
  'one-click-instance' => true,
  'one-click-instance.user-limit' => 100,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'check_data_directory_permissions' => false,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' =>
  array (
    'host' => 'nextcloud-aio-redis',
    'password' => 'xxx',
    'port' => 6379,
  ),
  'overwritehost' => 'cloud.xxx.com',
  'overwriteprotocol' => 'https',
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' =>
  array (
    0 => 'localhost',
    1 => 'cloud.xxx.com',
  ),
  'datadirectory' => '/mnt/ncdata',
  'dbtype' => 'pgsql',
  'version' => '32.0.6.1',
  'overwrite.cli.url' => 'https://cloud.xxx.com/',
  'dbname' => 'nextcloud_database',
  'dbhost' => 'nextcloud-aio-database:5432',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_nextcloud',
  'dbpassword' => 'xxx',
  'installed' => true,
  'instanceid' => 'oc1dxgkbbb60',
  'maintenance' => false,
  'loglevel' => 2,
  'log_type' => 'file',
  'logfile' => '/var/www/html/data/nextcloud.log',
  'log_rotate_size' => 10485760,
  'log.condition' =>
  array (
    'apps' =>
    array (
      0 => 'admin_audit',
    ),
  ),
  'preview_max_x' => 2048,
  'preview_max_y' => 2048,
  'jpeg_quality' => 60,
  'enabledPreviewProviders' =>
  array (
    0 => 'OC\\Preview\\Imaginary',
    1 => 'OC\\Preview\\MarkDown',
    2 => 'OC\\Preview\\MP3',
    3 => 'OC\\Preview\\TXT',
    4 => 'OC\\Preview\\OpenDocument',
    5 => 'OC\\Preview\\Movie',
    6 => 'OC\\Preview\\Krita',
    7 => 'OC\\Preview\\ImaginaryPDF',
    8 => 'OC\\Preview\\HEIC',
    9 => 'OC\\Preview\\TIFF',
    10 => 'OC\\Preview\\Imaginary',
    11 => 'OC\\Preview\\ImaginaryPDF',
    12 => 'OC\\Preview\\Image',
    23 => 'OC\\Preview\\ImaginaryPDF',
  ),
  'enable_previews' => true,
  'upgrade.disable-web' => true,
  'mail_smtpmode' => 'smtp',
  'trashbin_retention_obligation' => 'auto, 30',
  'versions_retention_obligation' => 'auto, 30',
  'activity_expire_days' => 30,
  'simpleSignUpLink.shown' => false,
  'share_folder' => '',
  'one-click-instance.link' => 'https://nextcloud.com/all-in-one/',
  'upgrade.cli-upgrade-link' => 'https://github.com/nextcloud/all-in-one/discussions/2726',
  'updatedirectory' => '/nc-updater',
  'maintenance_window_start' => 100,
  'allow_local_remote_servers' => true,
  'davstorage.request_timeout' => 3600,
  'documentation_url.server_logs' => 'https://github.com/nextcloud/all-in-one/discussions/5425',
  'htaccess.RewriteBase' => '/',
  'dbpersistent' => false,
  'auth.bruteforce.protection.enabled' => true,
  'ratelimit.protection.enabled' => true,
  'files_external_allow_create_new_local' => true,
  'trusted_proxies' =>
  array (
    0 => '127.0.0.1',
    1 => '::1',
    2 => '192.168.101.222',
    10 => '172.18.0.0/16',
  ),
  'preview_imaginary_url' => 'http://nextcloud-aio-imaginary:9000',
  'preview_imaginary_key' => 'xxx',
  'memories.db.triggers.fcu' => true,
  'memories.exiftool' => '/var/www/html/custom_apps/memories/bin-ext/exiftool-amd64-musl',
  'memories.vod.path' => '/var/www/html/custom_apps/memories/bin-ext/go-vod-amd64',
  'memories.vod.ffmpeg' => '/usr/bin/ffmpeg',
  'memories.vod.ffprobe' => '/usr/bin/ffprobe',
  'default_phone_region' => 'DE',
  'default_language' => 'de',
  'default_locale' => 'de_DE',
  'mail_smtphost' => 'xxx.xxx.com',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpport' => '465',
  'mail_from_address' => 'cloud',
  'mail_domain' => 'xxx.com',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'testing@xxx.com',
  'mail_smtppassword' => 'xxx',
  'forbidden_filename_characters' =>
  array (
    0 => '\\',
    1 => '/',
 ),
  'forbidden_filename_extensions' =>
  array (
    0 => '.filepart',
    1 => '.part',
  ),
  'memories.gis_type' => 2,
  'updatechecker' => false,
  'app_install_overwrite' =>
  array (
    0 => 'maps',
  ),
);

And that’s the data directory:

root@nextcloud:/srv/nextcloud/data# ls -lah
total 358K
drwxr-x---  3 www-data root        3 Feb 24  2016 '$2a$08$jtG'
drwxr-x--- 16 www-data root       22 Mar 24 14:20  .
drwxr-xr-x  3 www-data www-data    3 May 31  2025  ..
-rwxr-x---  1 www-data root      542 Feb 18 19:46  .htaccess
-rwxr-x---  1 www-data root       52 Feb 18 19:46  .ncdata
drwxr-x---  4 www-data root        4 Dec 19  2023  __groupfolders
drwxr-x---  5 www-data root        5 Jun  3  2025  admin
drwxr-x--- 16 www-data root       16 Jun  4  2025  appdata_oc1dxgkbbb60
drwxr-x--- 20 www-data root       20 May 18  2024  appdata_ocrciqqklyuf
-rwxr-x---  1 www-data root      18K May  7  2025  audit.log
drwxr-x---  6 www-data root        6 May 26  2019  avatars
drwxr-x---  2 www-data root        3 Jul  2  2024  files_external
-rwxr-x---  1 www-data root        0 May 10  2025  fts-index.done
drwxr-x---  6 www-data root        6 Feb  9  2020  heinz
-rwxr-x---  1 www-data root        0 Feb 18 19:46  index.html
drwxr-x--- 10 www-data root       10 Dec 11  2022  jana
drwxr-x---  6 www-data root        6 Aug 11  2024  moni
drwxr-x---  8 www-data root        8 Nov 23  2021  ulli
drwxr-x---  4 www-data root        5 May  7  2025  updater-ocrciqqklyuf
-rwxr-x---  1 www-data root     818K May  7  2025  updater.log
drwxr-x---  5 www-data root        5 Jan 24  2021  verena
drwxr-x--- 11 www-data root       11 Feb 23 23:49  wolf

The Basics

  • Nextcloud Server version (e.g., 29.x.x):
    • Nextcloud AIO v12.7.0, Nextcloud Hub 25 Autumn (32.0.6)
  • Operating system and version (e.g., Ubuntu 24.04):
    • Ubuntu 24.04 LTS LXC on Proxmox