Configuration was not read or initialized correctly

Hey,

sadly, I am currently facing problems with my nextcloud (official app) install on trueNAS. Hopefully, someone can help me.

Nextcloud version (eg, 20.0.5): 25.0.1
Operating system and version (eg, Ubuntu 20.04): TrueNAS-SCALE-22.02.4
Apache or nginx version (eg, Apache 2.4.25): Official TrueNAS App (Apache)
PHP version (eg, 7.4): 8.1.13

The issue you are facing:

The Nextcloud App wont start properly. The containers say deployed, however the web UI shows
"
Error
Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php
"

Is this the first time you’ve seen this error? Y

Steps to replicate it:

  1. Starting the App

The output of your Nextcloud log in Admin > Logging: Not available! Instead the Nextcloud app log

2022-12-23 16:38:08.173064+00:00Conf remoteip disabled.
2022-12-23 16:38:08.173102+00:00To activate the new configuration, you need to run:
2022-12-23 16:38:08.173107+00:00service apache2 reload
2022-12-23 16:38:08.264247+00:00AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.16.1.47. Set the 'ServerName' directive globally to suppress this message
2022-12-23 16:38:08.271374+00:00AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.16.1.47. Set the 'ServerName' directive globally to suppress this message
2022-12-23 16:38:08.284928+00:00[Fri Dec 23 16:38:08.284851 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.54 (Debian) PHP/8.1.13 configured -- resuming normal operations
2022-12-23 16:38:08.284947+00:00[Fri Dec 23 16:38:08.284879 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
2022-12-23 16:38:25.063440+00:00127.0.0.1 - - [23/Dec/2022:16:38:24 +0000] "GET / HTTP/1.1" 503 2752 "https://192.168.178.200/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15"
2022-12-23 16:43:26.161378+00:00127.0.0.1 - nils [23/Dec/2022:16:43:26 +0000] "GET /status.php HTTP/1.1" 500 397 "-" "Mozilla/5.0 (Macintosh) mirall/3.6.4git (build 12826) (Nextcloud, osx-22.1.0 ClientArchitecture: x86_64 OsArchitecture: x86_64)"
2022-12-23 16:43:55.228300+00:00127.0.0.1 - - [23/Dec/2022:16:43:55 +0000] "PUT /ocs/v2.php/apps/user_status/api/v1/heartbeat?format=json HTTP/1.1" 200 359 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15"
2022-12-23 16:43:55.228376+00:00127.0.0.1 - - [23/Dec/2022:16:43:55 +0000] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 200 359 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15"
2022-12-23 16:43:55.232891+00:00127.0.0.1 - - [23/Dec/2022:16:43:55 +0000] "GET /csrftoken HTTP/1.1" 503 2752 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.1 Safari/605.1.15"

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?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,
    ),
  ),
  'passwordsalt' => 'XXX',
  'secret' => 'XXX',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => '192.168.178.200',
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'pgsql',
  'version' => '25.0.1.1',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'nextcloud-postgres:5432',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'oc_nils',
  'dbpassword' => 'XXX',
  'installed' => true,
  'instanceid' => 'XXX',
  'overwritehost' => '192.168.178.200:9001',
  'overwriteprotocol' => 'https',
  'trusted_proxies' => 
  array (
    0 => '127.0.0.1',
  ),
  'maintenance' => true,
);

I wasn’t able to find any more logs useful information or non-empty logs…
Everything started with two files that could not be deleted in the web ui (“unable to delete …”) and sync client (" Server replied ‘423 Locked’ to DELETE ‘https://…’ "). There, I tried following the guide File is locked - how to unlock. Shortly after, I was met by even more problems, as explained above.

All data in the Nextcloud (except for the “deck” app) is backed up and safe. I was so far not able to back up the deck app after the general problem arose…

I would be happy for any help/information provided, as this is quite frustrating directly before Christmas. Thanks a lot in advance.
Cheers, Nils

Did you change anything in the config.php?

From the description, it sounds like a simple syntax error in the config.php, on a first glance I don’t see a problem in your config.php (perhaps the closing ?> at the end of the file but I’m not sure if that is optional, I’m not a php expert).

@tflidd, thank you for the reply.
I agree that it seems like a syntax error. However, I do not believe it is.
I am now one step closer to a possible solution…

Apparently, the permissions of the config.php changed (possibly when I added the " ‘maintenance’ => true, " line…). Following the commands from https://www.truenas.com/community/threads/nextcloud-app-external-storage.97726/post-674569, I was able to re-set www-data as the owner.

However, the nextcloud is currently not yet working again…
Now, the web interface changed to the error message:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

Next, when running occ commands, I got the message:

Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Nextcloud 25.0.1

After running

runuser -u www-data -- php occ upgrade

in the shell (bash in bin/sh), all commands for occ were available (note that the ix-systems application does not allow sudo commands and is not logged in as the user www-data! → hence the proceeding “runuser -u www-data”).
However,

runuser -u www-data -- php occ maintenance:repair

gave an error and request to reindex. Running

runuser -u www-data -- php occ files:scan --all

sadly only threw a lot of errors… However, I was able to backup the nextcloud deck now, as the occ deck:export command works :slight_smile:

I’ll have today sucessfully reinstall nextcloud and started over, as I didn’t see a possibility to repair or re-index the database and now had all data backed up.
Thanks a lot for the help and I hope I might help someone else with the explanations!

So i had the same error.

My problem was, i moved the nextcloud instance from one server (raspi 4 ubuntu) to another one( fedora server).
I exported the docker volumes on one server and imported them on the other one.
I also rsynced the local config folder to the new server.

After adding “:Z” to the volumes in the docker-compose it started but threw this
“Configuration was not read or initialized correctly” error.

So basically all the mounted folders had the user with the id 988 as the owner, but the nextcloud docker container needs them to be www-data.
I changed the owner and the group to www-data and now everything works just fine.

How to check if the owner is correct:

  1. Start the docker container (f.e. via docker-compose up -d)
  2. Enter the container by executing ‘docker-compose exec nextcloud /bin/bash’
  3. Check that the folder /var/www/html and all its content has owner www-data by executing ‘ls -la’
  4. If owner or group is different execute 'chown -R www-data:www-data ."
  5. Also execute the chown command for your nextcloud-data folder if its not mounted inside /var/www/html
  6. Optional: While being inside the docker you can also check for general problems. For example create a file inside the config folder or install nano (apt update && apt install) and check if you can change a value in the config.php file.

And now it should work

5 Likes

Hello there! I have had the exact same issue and your post helped me solve it. I honestly havent the foggiest how I changed the owner or why but this was it. 2 seconds after changing this, NC just began working again after a couple days of not working. I can’t thank you enough.

Have a good one!