Cannot access Nextcloud after an update ("Configuration was not read or initialized correctly")

Nextcloud version (eg, 20.0.5): 24.0.5.1
Operating system and version (eg, Ubuntu 20.04): Debian 11
Apache or nginx version (eg, Apache 2.4.25): Nginx 2.9.19
PHP version (eg, 7.4): 8.1.13

I updated my nextcloud instance (installed using Docker) like I usually do (by updating the docker images).

Now, when trying to access the web ui, I get an error message:
“Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php”

I am also facing this issue with Davx5 which shows an http error 500

I am guessing it might be because the update didn’t work properly, as the latest docker image is installed but the actual Nexcloud version is not and, the config.php file is empty.

Steps to replicate it:

  1. Go to the web ui
  2. Error message is shown
    “Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php”

Here is the log from nextcloud.log
{"reqId":"DQMxslL7c1hBMr17DBX1","level":3,"time":"2022-12-08T18:33:11+00:00","remoteAddr":"172.18.0.2","user":"--","app":"remote","method":"GET","url":"/remote.php/webdav/","message":"Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php","userAgent":"gnome-online-accounts/3.46.0 libsoup/3.2.2","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":142,"function":"setValue","class":"OC\\Config","type":"->","args":["instanceid","oc7pxu0a2ah5"]},{"file":"/var/www/html/lib/private/legacy/OC_Util.php","line":900,"function":"setValue","class":"OC\\SystemConfig","type":"->","args":["instanceid","oc7pxu0a2ah5"]},{"file":"/var/www/html/lib/base.php","line":430,"function":"getInstanceId","class":"OC_Util","type":"::","args":[]},{"file":"/var/www/html/lib/base.php","line":676,"function":"initSession","class":"OC","type":"::","args":[]},{"file":"/var/www/html/lib/base.php","line":1144,"function":"init","class":"OC","type":"::","args":[]},{"file":"/var/www/html/remote.php","line":119,"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","message":"Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php","exception":{},"CustomMessage":"Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php"}}
{"reqId":"AiuplGrdZ0X02GgdvuJT","level":3,"time":"2022-12-08T18:33:11+00:00","remoteAddr":"172.18.0.2","user":"--","app":"remote","method":"GET","url":"/remote.php/webdav/","message":"Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php","userAgent":"gnome-online-accounts/3.46.0 libsoup/3.2.2","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":142,"function":"setValue","class":"OC\\Config","type":"->","args":["instanceid","ocnsmm50cal7"]},{"file":"/var/www/html/lib/private/legacy/OC_Util.php","line":900,"function":"setValue","class":"OC\\SystemConfig","type":"->","args":["instanceid","ocnsmm50cal7"]},{"file":"/var/www/html/lib/base.php","line":430,"function":"getInstanceId","class":"OC_Util","type":"::","args":[]},{"file":"/var/www/html/lib/base.php","line":676,"function":"initSession","class":"OC","type":"::","args":[]},{"file":"/var/www/html/lib/base.php","line":1144,"function":"init","class":"OC","type":"::","args":[]},{"file":"/var/www/html/remote.php","line":119,"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","message":"Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php","exception":{},"CustomMessage":"Configuration was not read or initialized correctly, not overwriting /var/www/html/config/config.php"}}

How could I solve this issue?
I’ve already tried looking up for some solutions but they didn’t change anything, I’m not even sure where this problem is coming from.

Huge thanks in advance for your help!

I just had this same error message after updating an app.
In fact my config.php was empty … and my disk was full. Weird that nextcloud doesn’t make a backup of it before rewriting it.
I did some space and reverted the config file with the latest hourly snapshort and all seems to work fine again.