Nextcloud stopped working after using occ maintenance:repair

[English is not my native language so i used a translator, sorry for all mistakes]
I have a server with TrueNAS Scale, on which I installed Nextcloud as an application(Docker) from TrueCharts. Nextcloud was configured and everything worked, except for two errors in the protocol, which were:
Exception HMAC does not match. Could not decrypt or decode encrypted session data
and
Exception Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] could not translate host name “nextcloud-postgres” to address: Temporary failure in name resolution Exception thrown: Doctrine\DBAL\Exception

Despite these errors, it was possible to use Nextcloud normally, only sometimes there were problems with logging in, which could be solved by refreshing the browser. However, I wanted to solve these problems, so inside the Nextcloud container I logged in as the www-data user and executed the command occ maintenance:repair. Since the execution of this command and the restart of the Nextcloud container, it does not want to start anymore, the following error appears in the container log:
172.16.0.1 - - [09/Apr/2024:12:26:17 +0000] “GET /status.php HTTP/1.1” 500 410 “-” “kube-probe/1.26”
and in the nextcloud.log file I have such an error: {“reqId”:“4ZXCjLB6GMgJAJVS9QBW”,“level”:3,“time”:“2024-04-08T15:47:54+00:00”,“remoteAddr”:“172.16.0.1”,“user”:“–”,“app”:“remote”,“method”:“GET”,“url”:“/status.php”,“message”:“Exception thrown: OCP\HintException”,“userAgent”:“kube-probe/1.26”,“version”:“”,“exception”:{“Exception”:“OCP\HintException”,“Message”:“Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php”,“Code”:0,“Trace”:[{“file”:“/var/www/html/lib/private/Config.php”,“line”:143,“function”:“writeData”,“class”:“OC\Config”,“type”:“->”,“args”:[]},{“file”:“/var/www/html/lib/private/SystemConfig.php”,“line”:149,“function”:“setValue”,“class”:“OC\Config”,“type”:“->”,“args”:[“instanceid”,“ocp7utl3sd23”]},{“file”:“/var/www/html/lib/private/legacy/OC_Util.php”,“line”:850,“function”:“setValue”,“class”:“OC\SystemConfig”,“type”:“->”,“args”:[“instanceid”,“ocp7utl3sd23”]},{“file”:“/var/www/html/lib/base.php”,“line”:442,“function”:“getInstanceId”,“class”:“OC_Util”,“type”:“::”,“args”:[]},{“file”:“/var/www/html/lib/base.php”,“line”:705,“function”:“initSession”,“class”:“OC”,“type”:“::”,“args”:[]},{“file”:“/var/www/html/lib/base.php”,“line”:1200,“function”:“init”,“class”:“OC”,“type”:“::”,“args”:[]},{“file”:“/var/www/html/status.php”,“line”:37,“args”:[“/var/www/html/lib/base.php”],“function”:“require_once”}],“File”:“/var/www/html/lib/private/Config.php”,“Line”:266,“Hint”:“Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php”,“CustomMessage”:“Exception thrown: OCP\HintException”}}

Now I need to somehow find the specific cause of this problem and solve it, unfortunately, a clean reinstallation of Nextcloud is not an option. My theory of the origin of this problem is that the command occ maintenance:repair did not interpret changes in the context of using the container and perhaps the connection to the directory hosting Nextcloud outside the container was lost (or something simillar), as this was configured during the installation of this application in TrueNAS, in order to facilitate access to the Nextcloud configuration file and logs, as constantly entering the inside of the container is less convenient. Thanks for help.

There seems to be an issue with your config.php file. I would recommend checking the contents of that file and if it is valid PHP.

But the real config.php file is outside the container in /mnt/data01/apps/nextcloud

Docker container are little virtual environments. The file is mounted from the host (your NAS) into the virtual environment (the Docker container). So it should be the same file.

I’m not sure, but i think the maintenance:repair command turns on the maintenance mode (which is in there) and then this error occurs.

My first guess would be that the file has been altered and currently does not contain valid PHP code.

I dont see anything sus:

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  '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,
    ),
  ),
  'upgrade.disable-web' => true,
  'passwordsalt' => '1q7Efq5yd2FR0HgHb/a5ae1NxkkE8D',
  'secret' => '8m3VkecvXEzG5t79LSJ7UFR1wF9fOCbKnbX0e2y37Kycxom0',
  'trusted_domains' => 
  array (
    0 => '192.168.2.148:9001',
    1 => '[HIDDEN]',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'pgsql',
  'version' => '28.0.4.1',
  'overwrite.cli.url' => '[HIDDEN]',
  'overwritehost' => '[HIDDEN]',
  'overwriteprotocol' => 'https',
  'dbname' => 'nextcloud',
  'dbhost' => 'nextcloud-postgres:5432',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_admin',
  'dbpassword' => '[HIDDEN]',
  'installed' => true,
  'instanceid' => 'octx60gyxnn9',
  'default_phone_region' => 'DE',
  'loglevel' => 2,
  'maintenance' => false,
  'default_language' => 'de',
  'default_locale' => 'de_DE',
  'mail_from_address' => '[HIDDEN]',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'hotmail.com',
  'mail_smtphost' => 'smtp-mail.outlook.com',
  'mail_smtpport' => '	587 587',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '[HIDDEN]',
  'mail_smtppassword' => '[HIDDEN]',
  'maintenance_window_start' => '1',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '192.168.2.148',
    'port' => 30036,
    'password' => '[HIDDEN]',
  ),
);

I managed to solve the issue. I’m not certain if the occ maintenance:repair command altered any permissions, but all I had to do was assign the config.php file to the www-data user and grant it the appropriate permissions like it was before(I think). Now, Nextcloud is back up and running smoothly without any errors or issues.

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