Since Version 29 of NextCloud my DB Connection breaks

So I run Nextcloud as a container on Unraid. I use MariaDB as my DB. Currently its set to version 11.4 but this issue was also on 10.x.

Since I updated to NC version 29.x onwards Nextcloud boots and runs ok and I can use it but then after a few hours or next day I see the following error in NC logs:

octrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused in /app/www/public/lib/private/DB/Connection.php:233
Stack trace:
#0 /app/www/public/3rdparty/doctrine/dbal/src/Connection.php(453): OC\DB\Connection->connect()
#1 /app/www/public/3rdparty/doctrine/dbal/src/Connection.php(411): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /app/www/public/3rdparty/doctrine/dbal/src/Connection.php(318): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /app/www/public/lib/private/DB/Connection.php(899): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /app/www/public/lib/private/DB/ConnectionAdapter.php(235): OC\DB\Connection->getDatabaseProvider()
#5 /app/www/public/lib/private/DB/QueryBuilder/QueryBuilder.php(96): OC\DB\ConnectionAdapter->getDatabaseProvider()
#6 /app/www/public/lib/private/AppConfig.php(1211): OC\DB\QueryBuilder\QueryBuilder->expr()
#7 /app/www/public/lib/private/AppConfig.php(237): OC\AppConfig->loadConfig()
#8 /app/www/public/lib/private/AppConfig.php(1351): OC\AppConfig->searchValues()
#9 /app/www/public/lib/private/App/AppManager.php(126): OC\AppConfig->getValues()
#10 /app/www/public/lib/private/App/AppManager.php(147): OC\App\AppManager->getInstalledAppsValues()
#11 /app/www/public/lib/private/legacy/OC_App.php(191): OC\App\AppManager->getInstalledApps()
#12 /app/www/public/lib/private/AppFramework/Bootstrap/Coordinator.php(48): OC_App::getEnabledApps()
#13 /app/www/public/lib/base.php(657): OC\AppFramework\Bootstrap\Coordinator->runInitialRegistration()
#14 /app/www/public/lib/base.php(1132): OC::init()
#15 /app/www/public/cron.php(24): require_once('...')
#16 {main}

If I restart NC it works again until random amount of time and then breaks.
Other apps running on my DB are unaffected.
Any help?

Same issue, but mine fails on startup. I use docker nextcloud (28.0.8 is latest) with mariaDB 10.3.22 in a separate container. Web server says:

“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.”

nextcloud.log is full of:

“Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection refused”

Edit: After several failed restarts, including removing all containers and images, it started up ok on 28.0.8 for some reason.

Edit2: Nope, it just came up momentarily before getting these errors:
“Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2006] MySQL server has gone away”

Check your database container log. All the Nextcloud container can tell you is that there’s a problem with your database server.

Sorry for not posting that. There were no hints in the DB container logs, everything started ok and no sign of any attempts to connect.

Again, it magically started up now and keeps running since yesterday. Happy for now, I’ll come back if the problem reoccurs.