The basics
Nextcloud version: nextcloud:stable-fpm-alpine@sha256:fd092d936643c2e0c0b80c27d5518c793e5e215d5b5836e5ecdca973395b2c34
Operating system: Truenas scale 2410
The issue
I just upgraded the postgres server for my nextcloud instance. from 16 to 17.
I followed the normal procedure and did a pg_dump and imported that in a fresh postgres 17 server and once everything was running fine again I spun down the container and spun it back up with the rest of the nextcloud container components. (redis, nextcloud, nextcloud_cron)
However once it all started back up I am no longer able to connect the my nextcloud and based on the nextcloud.log it seems that nextcloud is for some reason unable to connect to the postgres database.
Based on what I can understand it seems to be unable to resolve the hostname to the postgres database, which I do not understand.
I can verify that POSTGRES_USER, POSTGRES_HOST, POSTGRES_DB and POSTGRES_PASSWORD are all set correctly and I myself can psql connect to the database from the nextcloud container by using
psql -h $POSTGRES_HOST -p 5432 -U $POSTGRES_USER -d $POSTGRES_DB
I found the following related topic: How to upgrade postgresql from V13 to V14 or V15 - #5 by abinoam
where someone suggested to look in config.php and confirm that the username and password were correct, and there were some issues there, which I fixed. However, the hostname was correct, and it seems to already stumble on that part.
Did I forget to change anything else? Or can anyone else see what I’m missing or messed up?
tail end of the nextcloud.log file:
{"reqId":"wkqWxVSUiI2kaRVvbzqa","level":3,"time":"2025-02-28T13:05:57+00:00","remoteAddr":"127.0.0.1","user":"--","app":"core","method":"GET","url":"/","message":"Exception thrown: Doctrine\\DBAL\\Exception","userAgent":"curl/7.88.1","version":"29.0.8.1","exception":{"Exception":"Doctrine\\DBAL\\Exception","Message":"Failed to connect to the database: An exception occurred in the driver: SQLSTATE[08006] [7] could not translate host name \"postgres\" to address: No address associated with hostname","Code":7,"Trace":[{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":453,"function":"connect","class":"OC\\DB\\Connection","type":"->","args":[]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":411,"function":"getDatabasePlatformVersion","class":"Doctrine\\DBAL\\Connection","type":"->","args":[]},{"file":"/var/www/html/3rdparty/doctrine/dbal/src/Connection.php","line":318,"function":"detectDatabasePlatform","class":"Doctrine\\DBAL\\Connection","type":"->","args":[]},{"file":"/var/www/html/lib/private/DB/ConnectionAdapter.php","line":200,"function":"getDatabasePlatform","class":"Doctrine\\DBAL\\Connection","type":"->","args":[]},{"file":"/var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php","line":121,"function":"getDatabasePlatform","class":"OC\\DB\\ConnectionAdapter","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppConfig.php","line":1239,"function":"expr","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->","args":[]},{"file":"/var/www/html/lib/private/AppConfig.php","line":264,"function":"loadConfig","class":"OC\\AppConfig","type":"->","args":[false]},{"file":"/var/www/html/lib/private/legacy/OC_App.php","line":736,"function":"searchValues","class":"OC\\AppConfig","type":"->","args":["installed_version"]},{"file":"/var/www/html/lib/private/TemplateLayout.php","line":237,"function":"getAppVersions","class":"OC_App","type":"::","args":[]},{"file":"/var/www/html/lib/private/legacy/OC_Template.php","line":145,"function":"__construct","class":"OC\\TemplateLayout","type":"->","args":["error",""]},{"file":"/var/www/html/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":"OC_Template","type":"->","args":[]},{"file":"/var/www/html/lib/private/legacy/OC_Template.php","line":320,"function":"printPage","class":"OC\\Template\\Base","type":"->","args":[]},{"file":"/var/www/html/index.php","line":114,"function":"printExceptionErrorPage","class":"OC_Template","type":"::","args":[["Doctrine\\DBAL\\Exception"],500]}],"File":"/var/www/html/lib/private/DB/Connection.php","Line":167,"CustomMessage":"Exception thrown: Doctrine\\DBAL\\Exception"}}