OCC has Database problem: "Failed to connect to the database"

Steps to reproduce

run the occ command

Expected behaviour

showing anything others then errors if using occ. The Website works well and has no problem.

Actual behaviour

An unhandled exception has been thrown:
exception 'Doctrine\DBAL\DBALException' with message 'Failed to connect to the database: An exception occured in driver: SQLSTATE[HY0$
Stack trace:
#0 /CL/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
#1 /CL/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /CL/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /CL/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /CL/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /CL/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Dri$
#6 /CL/lib/private/DB/ConnectionFactory.php(153): Doctrine\DBAL\DriverManager::getConnection(Array, Object(Doctrine\DBAL\Configuratio$
#7 /CL/lib/private/Server.php(628): OC\DB\ConnectionFactory->getConnection('mysql', Array)
#8 /CL/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#9 /CL/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OCP\\IDBConnecti...')
#10 /CL/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OCP\\IDBConnecti...')
#11 /CL/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query('OCP\\IDBConnecti...')
#12 /CL/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closu$
#13 /CL/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('DatabaseConnect...')
#14 /CL/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('DatabaseConnect...')
#15 /CL/lib/private/Server.php(1511): OC\ServerContainer->query('DatabaseConnect...')
#16 /CL/lib/private/Server.php(332): OC\Server->getDatabaseConnection()
#17 /CL/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#18 /CL/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OC\\Authenticati...')
#19 /CL/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#20 /CL/lib/private/Server.php(336): OC\ServerContainer->query('OC\\Authenticati...')
#21 /CL/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#22 /CL/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OC\\Authenticati...')
#23 /CL/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#24 /CL/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query('OC\\Authenticati...')
#25 /CL/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closu$
#26 /CL/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OC\\Authenticati...')
#27 /CL/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#28 /CL/lib/private/Server.php(352): OC\ServerContainer->query('OC\\Authenticati...')
#29 /CL/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#30 /CL/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OCP\\IUserSessio...')
#31 /CL/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OCP\\IUserSessio...')
#32 /CL/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query('OCP\\IUserSessio...')
#33 /CL/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closu$
#34 /CL/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('UserSession')
#35 /CL/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('UserSession')
#36 /CL/lib/private/Server.php(1380): OC\ServerContainer->query('UserSession')
#37 /CL/lib/private/Server.php(688): OC\Server->getUserSession()
#38 /CL/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#39 /CL/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OC\\App\\AppManag...')
#40 /CL/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\App\\AppManag...')
#41 /CL/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query('OC\\App\\AppManag...')
#42 /CL/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closu$
#43 /CL/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('AppManager')
#44 /CL/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('AppManager')
#45 /CL/lib/private/Server.php(1684): OC\ServerContainer->query('AppManager')
#46 /CL/lib/private/legacy/app.php(332): OC\Server->getAppManager()
#47 /CL/lib/private/legacy/app.php(113): OC_App::getEnabledApps()
#48 /CL/lib/base.php(662): OC_App::loadApps(Array)
#49 /CL/lib/base.php(1081): OC::init()
#50 /CL/console.php(46): require_once('/CL/lib/base.ph...')
#51 /CL/occ(11): require_once('/CL/console.php')
#52 {main}

Server configuration detail

Operating system: Linux 3.10.0-693.11.6.el7.x86_64 #1 SMP Thu Jan 4 01:06:37 UTC 2018 x86_64

Webserver: Apache (fpm-fcgi)

Database: mysql 10.1.32

PHP version: 7.1.19
Modules loaded: Core, date, libxml, openssl, pcre, zlib, bz2, calendar, ctype, hash, filter, ftp, gettext, gmp, SPL, iconv, Reflection, session, standard, SimpleXML, sockets, mbstring, tokenizer, xml, cgi-fcgi, mysqlnd, bcmath, curl, dba, dom, fileinfo, gd, imagick, imap, intl, json, exif, mcrypt, mysqli, odbc, PDO, pdo_mysql, PDO_ODBC, pdo_sqlite, Phar, posix, pspell, soap, sqlite3, sysvmsg, sysvsem, sysvshm, xmlreader, xmlrpc, xmlwriter, xsl, zip, ionCube Loader, Zend OPcache

Nextcloud version: 13.0.2 - 13.0.2.1

Updated from an older Nextcloud/ownCloud or fresh install: Yes

Signing status

Array

List of activated apps
Enabled:
 - admin_audit: 1.3.0
 - apporder: 0.4.1
 - audioplayer: 2.3.0
 - bruteforcesettings: 1.0.3
 - calendar: 1.6.1
 - comments: 1.3.0
 - contacts: 2.1.5
 - dav: 1.4.6
 - federatedfilesharing: 1.3.1
 - federation: 1.3.0
 - files: 1.8.0
 - files_external: 1.4.1
 - files_markdown: 2.0.4
 - files_pdfviewer: 1.2.1
 - files_sharing: 1.5.0
 - files_texteditor: 2.5.1
 - files_trashbin: 1.3.0
 - files_versions: 1.6.0
 - files_videoplayer: 1.2.0
 - firstrunwizard: 2.2.1
 - gallery: 18.0.0
 - gpxedit: 0.0.8
 - gpxmotion: 0.0.6
 - gpxpod: 2.2.2
 - impersonate: 1.0.4
 - issuetemplate: 0.3.0
 - logreader: 2.0.0
 - lookup_server_connector: 1.1.0
 - mail: 0.8.1
 - mindmaps: 0.1.0
 - nextcloud_announcements: 1.2.0
 - notes: 2.3.2
 - notifications: 2.1.2
 - oauth2: 1.1.0
 - ojsxc: 3.4.0
 - password_policy: 1.3.0
 - piwik: 0.4.1
 - polls: 0.8.1
 - provisioning_api: 1.3.0
 - serverinfo: 1.3.0
 - sharebymail: 1.3.0
 - spreed: 3.2.2
 - survey_client: 1.1.0
 - systemtags: 1.3.0
 - theming: 1.4.5
 - twofactor_backupcodes: 1.2.3
 - updatenotification: 1.3.0
 - workflowengine: 1.3.0
Disabled:
 - activity
 - deck
 - encryption
 - external
 - user_external
 - user_ldap

Configuration (config/config.php)
{
    "maintenance": false,
    "installed": true,
    "default_language": "de",
    "knowledgebaseenabled": true,
    "enable_avatars": true,
    "theme": "",
    "allow_user_to_change_display_name": true,
    "remember_login_cookie_lifetime": 1296000,
    "session_lifetime": 86400,
    "session_keepalive": true,
    "token_auth_enforced": false,
    "auth.bruteforce.protection.enabled": true,
    "mail_smtpdebug": false,
    "htaccess.RewriteBase": "\/",
    "trashbin_retention_obligation": "300,auto",
    "versions_retention_obligation": "90, auto",
    "appcodechecker": true,
    "updatechecker": true,
    "updater.server.url": "https:\/\/updates.nextcloud.com\/updater_server\/",
    "updater.release.channel": "stable",
    "has_internet_connection": true,
    "appstoreenabled": true,
    "enable_previews": true,
    "preview_max_x": 2048,
    "preview_max_y": 2048,
    "preview_max_scale_factor": 10,
    "preview_max_filesize_image": 2,
    "check_for_working_webdav": true,
    "check_for_working_wellknown_setup": true,
    "check_for_working_htaccess": true,
    "config_is_read_only": false,
    "version": "13.0.2.1",
    "dbtype": "mysql",
    "dbtableprefix": "oc_",
    "logfile": "\/home\/httpd\/vhosts\/Marco\/http-daten\/nextcloud.log",
    "loglevel": 0,
    "syslog_tag": "Cloud",
    "logdateformat": "Y.m.d, H:i:s",
    "logtimezone": "Europe\/Berlin",
    "log_query": false,
    "cron_log": true,
}

Are you using encryption: no

Are you using an external user-backend, if yes which one: IMAP

Logs

Browser log
2018-07-09 09:50:04	Access	178.197.228.217	200	GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.0
Nextcloud log
No etries

Hi,

Could you please paste the occ command that you try to execute?
Please paste the the latest entries of Nextcloud.log

I get this from command occ -h
If I remove Nextcloud.log, enter this command and then open Nextcloud.log I have no entry.

Someone any Idea?

Also getting the same problem whenever using occ, even with no arguments:

$ sudo -u www php occ -h
An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /www/wwwroot/nextcloud/lib/private/DB/Connection.php:64
Stack trace:
#0 /www/wwwroot/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
#1 /www/wwwroot/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /www/wwwroot/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /www/wwwroot/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /www/wwwroot/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /www/wwwroot/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#6 /www/wwwroot/nextcloud/lib/private/DB/ConnectionFactory.php(158): Doctrine\DBAL\DriverManager::getConnection(Array, Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#7 /www/wwwroot/nextcloud/lib/private/Server.php(640): OC\DB\ConnectionFactory->getConnection('mysql', Array)
#8 /www/wwwroot/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#9 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet('OCP\\IDBConnecti...')
#10 /www/wwwroot/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OCP\\IDBConnecti...')
#11 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(165): OC\ServerContainer->query('OCP\\IDBConnecti...')
#12 /www/wwwroot/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#13 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet('DatabaseConnect...')
#14 /www/wwwroot/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('DatabaseConnect...')
#15 /www/wwwroot/nextcloud/lib/private/Server.php(1551): OC\ServerContainer->query('DatabaseConnect...')
#16 /www/wwwroot/nextcloud/lib/private/Server.php(360): OC\Server->getDatabaseConnection()
#17 /www/wwwroot/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#18 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet('OC\\Authenticati...')
#19 /www/wwwroot/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#20 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(68): OC\ServerContainer->query('OC\\Authenticati...')
#21 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(98): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#22 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(119): OC\AppFramework\Utility\SimpleContainer->resolve('OC\\Authenticati...')
#23 /www/wwwroot/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#24 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(68): OC\ServerContainer->query('OC\\Authenticati...')
#25 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(98): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#26 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(119): OC\AppFramework\Utility\SimpleContainer->resolve('OC\\Authenticati...')
#27 /www/wwwroot/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#28 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(165): OC\ServerContainer->query('OC\\Authenticati...')
#29 /www/wwwroot/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#30 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet('OC\\Authenticati...')
#31 /www/wwwroot/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#32 /www/wwwroot/nextcloud/lib/private/Server.php(372): OC\ServerContainer->query('OC\\Authenticati...')
#33 /www/wwwroot/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#34 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet('OC\\User\\Session')
#35 /www/wwwroot/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\User\\Session')
#36 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(165): OC\ServerContainer->query('OC\\User\\Session')
#37 /www/wwwroot/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#38 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet('UserSession')
#39 /www/wwwroot/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('UserSession')
#40 /www/wwwroot/nextcloud/lib/private/Server.php(1427): OC\ServerContainer->query('UserSession')
#41 /www/wwwroot/nextcloud/lib/private/Server.php(693): OC\Server->getUserSession()
#42 /www/wwwroot/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#43 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet('OC\\App\\AppManag...')
#44 /www/wwwroot/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\App\\AppManag...')
#45 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(165): OC\ServerContainer->query('OC\\App\\AppManag...')
#46 /www/wwwroot/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#47 /www/wwwroot/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet('AppManager')
#48 /www/wwwroot/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('AppManager')
#49 /www/wwwroot/nextcloud/lib/private/Server.php(1722): OC\ServerContainer->query('AppManager')
#50 /www/wwwroot/nextcloud/lib/private/legacy/app.php(342): OC\Server->getAppManager()
#51 /www/wwwroot/nextcloud/lib/private/legacy/app.php(113): OC_App::getEnabledApps()
#52 /www/wwwroot/nextcloud/lib/base.php(654): OC_App::loadApps(Array)
#53 /www/wwwroot/nextcloud/lib/base.php(1068): OC::init()
#54 /www/wwwroot/nextcloud/console.php(46): require_once('/www/wwwroot/ne...')
#55 /www/wwwroot/nextcloud/occ(11): require_once('/www/wwwroot/ne...')
#56 {main}PHP Fatal error:  Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /www/wwwroot/nextcloud/lib/private/DB/Connection.php:64
Stack trace:
#0 /www/wwwroot/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
#1 /www/wwwroot/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /www/wwwroot/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /www/wwwroot/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /www/wwwroot/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /www/wwwroot/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\ in /www/wwwroot/nextcloud/lib/private/DB/Connection.php on line 64

Tried listing all modules that php is using:

$ php -m                
[PHP Modules]
apc
apcu
calendar
Core
ctype
date
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
Zend OPcache
zlib
[Zend Modules]
Zend OPcache

It seems that mysqli and pdo_mysql are all working normally. MariaDB is also online. The website is working normally. Just having problems when using occ in CLI.
Running Nextcloud v15.0.0 on Ubuntu 18.04 LTS.
Webserver is nginx 1.14.1.
PHP version is 7.2.10.

2 Likes

I too have excately this problem :dizzy_face: running almost identical configuration as the above examples :bangbang:

I was able to get occ access over a Nextcloud app (seems there is really an app for everything :laughing:)
https://apps.nextcloud.com/apps/occweb

3 Likes

I have the same problem too, can anybody help on this?

My problem was solved when mysqli part of php config for commandline was made equal to the one for my webserver.

1 Like

my problem is resolved by changing localhost to 127.0.0.1 in config.php file

After I was able to get the content of the php.ini file from my webspace I was able to get occ working from ssh.

I created a ~/.bashrc file containing:
occ() { {PathToPhp} -c {PathTo/Php.ini} {PathTo/occ} $@ }

because .bashrc do not get loaded automatically I start it my self after logging into ssh:
source .bashrc

now I could start occ commands:
occ files:scan --all

After an Update from my hoster they separated the file structure of ssh and php.
To be able to still use ssh. I had to fake the filestructure with symbolic links on ssh. The goal was to have the directory structure like in the nextcloud config.

The other point I had to do was granting ssh the possibility to access to the database.
My hoster use Plesk so I had to do that in this tool.

I have searched almost all of google for this but i just cannot get it to work. I am trying to setup notify_push

Had same error yesterday during/after upgrade from 27.1.5 to 28.0.2 under Ubuntu 22.04 LTS with MariaDb 10.6.16, PHP 8.1 and Apache 2.4.52 for a system with all current updates.
When I clicked the continue with webupdater button, I got a white screen. So tried the the cli workaround:
sudo -u www-data php /var/www/html/occ upgrade
and got the error message of this thread.
The workaround from Mannshoch did not work for me. The replacement of localhost with 127.0.0.1 is restricting possible IPv6 capabilities to IPv4.
I had had similar error messages on my private nextcloudpi RaspberryPi 4B installation several times last year. Each time the database connection did not work. For that case the only solution was to wait either for the next php update or nextcloud update. It was like pingpong. Each time a new php update came, the state changed, some times immediatly, some times after reboot.
Are there any known PHP issues with mysql/mariadb? Or other question: Does the upgrade change any php (config) files regarding connecting to database?
For a production system waiting for the next update is only an option after restoring the image backup, done just before the upgrade. So I did and will give Nextcloud 28 the next try on either the next version or after a PHP update or an official workaround.