Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nextcloud 18 using docker-compose: Failed to connect to the database #1114

Closed
makayabou opened this issue May 8, 2020 · 5 comments
Closed

Comments

@makayabou
Copy link

I upgraded my Debian 10 on a VM hosted by gandi. Then reboot and restart my instance using docker-compose up -d.
However I get "Internal Server Error" message on browser, and then, trying to use command-line:

makayabou@gnprod:/opt/gntools/config/nextcloud$ sudo docker-compose exec -u www-data nextcloud php occ -h
An unhandled exception has been thrown:
Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occurred in driver: SQLSTATE[HY000] [2002] Connection refused in /var/www/html/lib/private/DB/Connection.php:68
Stack trace:
#0 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(420): OC\DB\Connection->connect()
#1 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(380): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(324): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(683): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /var/www/html/lib/private/DB/Connection.php(155): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(195): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#6 /var/www/html/lib/private/DB/ConnectionFactory.php(157): Doctrine\DBAL\DriverManager::getConnection(Array, Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#7 /var/www/html/lib/private/Server.php(749): OC\DB\ConnectionFactory->getConnection('mysql', Array)
#8 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#9 /var/www/html/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('OCP\\IDBConnecti...')
#10 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\ServerContainer->query('OCP\\IDBConnecti...')
#11 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#12 /var/www/html/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('DatabaseConnect...')
#13 /var/www/html/lib/private/Server.php(1666): OC\ServerContainer->query('DatabaseConnect...')
#14 /var/www/html/lib/private/Server.php(422): OC\Server->getDatabaseConnection()
#15 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#16 /var/www/html/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('OC\\Authenticati...')
#17 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(70): OC\ServerContainer->query('OC\\Authenticati...', true)
#18 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(100): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#19 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(115): OC\AppFramework\Utility\SimpleContainer->resolve('OC\\Authenticati...')
#20 /var/www/html/lib/private/ServerContainer.php(150): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...', true)
#21 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(70): OC\ServerContainer->query('OC\\Authenticati...', true)
#22 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(100): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#23 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(115): OC\AppFramework\Utility\SimpleContainer->resolve('OC\\Authenticati...')
#24 /var/www/html/lib/private/ServerContainer.php(150): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...', true)
#25 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\ServerContainer->query('OC\\Authenticati...')
#26 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#27 /var/www/html/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('OC\\Authenticati...')
#28 /var/www/html/lib/private/Server.php(434): OC\ServerContainer->query('OC\\Authenticati...')
#29 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#30 /var/www/html/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('OC\\User\\Session')
#31 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\ServerContainer->query('OC\\User\\Session')
#32 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#33 /var/www/html/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('UserSession')
#34 /var/www/html/lib/private/Server.php(1542): OC\ServerContainer->query('UserSession')
#35 /var/www/html/lib/private/Server.php(802): OC\Server->getUserSession()
#36 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC\{closure}(Object(OC\Server))
#37 /var/www/html/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('OC\\App\\AppManag...')
#38 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(162): OC\ServerContainer->query('OC\\App\\AppManag...')
#39 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#40 /var/www/html/lib/private/ServerContainer.php(125): Pimple\Container->offsetGet('AppManager')
#41 /var/www/html/lib/private/Server.php(1837): OC\ServerContainer->query('AppManager')
#42 /var/www/html/lib/private/legacy/app.php(347): OC\Server->getAppManager()
#43 /var/www/html/lib/private/legacy/app.php(114): OC_App::getEnabledApps()
#44 /var/www/html/lib/base.php(645): OC_App::loadApps(Array)
#45 /var/www/html/lib/base.php(1089): OC::init()
#46 /var/www/html/console.php(48): require_once('/var/www/html/l...')
#47 /var/www/html/occ(11): require_once('/var/www/html/c...')
#48 {main}makayabou@gnprod:/opt/gntools/config/nextcloud$ sudo docker-compose ps
          Name                        Command               State           Ports         
------------------------------------------------------------------------------------------
nextcloud_databasenext_1   docker-entrypoint.sh mysqld      Up      3306/tcp              
nextcloud_nextcloud_1      /entrypoint.sh apache2-for ...   Up      127.0.0.1:8889->80/tcp
nextcloud_redisnext_1      docker-entrypoint.sh redis ...   Up      6379/tcp   

I saw other posts saying it was a problem with php version, but as it is deployed with docker-compose, the problem should be somewhere else..

Thanks for helping, and thanks for nextcloud via docker

@gandalfk7
Copy link

Hi, I am going to open a separate issue for this,
I was using the mariadb-redis-apache (or fpm) docker-compose files but all failed similar to yours,
I've found this issue: MariaDB/mariadb-docker#262
Which led me to apply this change in my docker-compose file:
from:
services: db: image: mariadb
to:
services: db: image: mariadb:10.3.22

and now it works correctly.

Before the change it would ignore the MYSQL_ROOT_PASSWORD parameter in the environment and the other parameters in db.env.
A workaround that works with the latest versions is to apply the parameter "MYSQL_INITDB_SKIP_TZINFO=1" to mariadb, I've tested it and it works correctly. (but I prefer something older that works as it should, so I reverted to an older version)

@makayabou
Copy link
Author

makayabou commented May 9, 2020

Hello,
I tried changing mariadb image to 10.3.22, and also add MYSQL_INITDB_SKIP_TZINFO=1 to mariadb docker ENV but neither nor both worked..
So i'm not sure it's related to #1038
Also, I did not use db.env, all parameters were in my docker-compose.yml , but even If I add it, no changes..

@drptbl
Copy link

drptbl commented May 18, 2020

Same issue, solutions above didn't help.
Ubuntu 18 on DigitalOcean VPS.

@peterspat
Copy link

Can still confirm this problem.

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.

@J0WI
Copy link
Contributor

J0WI commented Apr 4, 2023

#1007

@J0WI J0WI closed this as completed Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants