Nextcloud 14 works fine from the browser but I can't do any occ commands without massive DB connection errors

[details=“Support intro”]
Hi, I recently installed Nextcloud 14 on a Synology 918+ using WebStation, MariaDB, Php 7.0 and of course downloading the latest Nextcloud 14 zip file. The package sets up as expected and is accessible via the web, and through clients on Macs and PCs, however, when I go into the command line interface via ssh - get the following error-

Here is my set up:

NextCloud 14, Synology 918+ with latest DSM, Maria DB 10, Php 7.0, basically latest everything... diagnostics
                                                                                                                                                                                                                                                                          

The issue you are facing:

An unhandled exception has been thrown:

Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /volume1/web/nextcloud/lib/private/DB/Connection.php:64

Stack trace:

#0 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()

#1 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()

#2 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()

#3 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()

#4 /volume1/web/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)

#5 /volume1/web/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 /volume1/web/nextcloud/lib/private/DB/ConnectionFactory.php(152): Doctrine\DBAL\DriverManager::getConnection(Array, Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))

#7 /volume1/web/nextcloud/lib/private/Server.php(630): OC\DB\ConnectionFactory->getConnection(‘mysql’, Array)

#8 /volume1/web/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))

#9 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet(‘OCP\IDBConnecti…’)

#10 /volume1/web/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OCP\IDBConnecti…’)

#11 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(165): OC\ServerContainer->query(‘OCP\IDBConnecti…’)

#12 /volume1/web/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(OC\Server))

#13 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet(‘DatabaseConnect…’)

#14 /volume1/web/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘DatabaseConnect…’)

#15 /volume1/web/nextcloud/lib/private/Server.php(1533): OC\ServerContainer->query(‘DatabaseConnect…’)

#16 /volume1/web/nextcloud/lib/private/Server.php(352): OC\Server->getDatabaseConnection()

#17 /volume1/web/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))

#18 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet(‘OC\Authenticati…’)

#19 /volume1/web/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OC\Authenticati…’)

#20 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(68): OC\ServerContainer->query(‘OC\Authenticati…’)

#21 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(98): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))

#22 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(119): OC\AppFramework\Utility\SimpleContainer->resolve(‘OC\Authenticati…’)

#23 /volume1/web/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OC\Authenticati…’)

#24 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(68): OC\ServerContainer->query(‘OC\Authenticati…’)

#25 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(98): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))

#26 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(119): OC\AppFramework\Utility\SimpleContainer->resolve(‘OC\Authenticati…’)

#27 /volume1/web/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OC\Authenticati…’)

#28 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(165): OC\ServerContainer->query(‘OC\Authenticati…’)

#29 /volume1/web/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(OC\Server))

#30 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet(‘OC\Authenticati…’)

#31 /volume1/web/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OC\Authenticati…’)

#32 /volume1/web/nextcloud/lib/private/Server.php(364): OC\ServerContainer->query(‘OC\Authenticati…’)

#33 /volume1/web/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))

#34 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet(‘OCP\IUserSessio…’)

#35 /volume1/web/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OCP\IUserSessio…’)

#36 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(165): OC\ServerContainer->query(‘OCP\IUserSessio…’)

#37 /volume1/web/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(OC\Server))

#38 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet(‘UserSession’)

#39 /volume1/web/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘UserSession’)

#40 /volume1/web/nextcloud/lib/private/Server.php(1409): OC\ServerContainer->query(‘UserSession’)

#41 /volume1/web/nextcloud/lib/private/Server.php(683): OC\Server->getUserSession()

#42 /volume1/web/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\Server->OC{closure}(Object(OC\Server))

#43 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet(‘OC\App\AppManag…’)

#44 /volume1/web/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘OC\App\AppManag…’)

#45 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(165): OC\ServerContainer->query(‘OC\App\AppManag…’)

#46 /volume1/web/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility{closure}(Object(OC\Server))

#47 /volume1/web/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(117): Pimple\Container->offsetGet(‘AppManager’)

#48 /volume1/web/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query(‘AppManager’)

#49 /volume1/web/nextcloud/lib/private/Server.php(1704): OC\ServerContainer->query(‘AppManager’)

#50 /volume1/web/nextcloud/lib/private/legacy/app.php(342): OC\Server->getAppManager()

#51 /volume1/web/nextcloud/lib/private/legacy/app.php(113): OC_App::getEnabledApps()

#52 /volume1/web/nextcloud/lib/base.php(654): OC_App::loadApps(Array)

#53 /volume1/web/nextcloud/lib/base.php(1068): OC::init()

#54 /volume1/web/nextcloud/console.php(46): require_once(’/volume1/web/ne…’)

#55 /volume1/web/nextcloud/occ(11): require_once(’/volume1/web/ne…’)

#56 {main}PHP Fatal error: Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /volume1/web/nextcloud/lib/private/DB/Connection.php:64

Stack trace:

#0 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()

#1 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()

#2 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()

#3 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()

#4 /volume1/web/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)

#5 /volume1/web/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object(Doctrine\DBAL\Driver\PDOMySql\Driver), Ob in /volume1/web/nextcloud/lib/private/DB/Connection.php on line 64

Is this the first time you’ve seen this error? (Y/N):

If I use Php5.6 I get an error saying I need to use 7.0, and messing with the config.php hasn’t produced any thing diffrerent.

Steps to replicate it:

  1. command line on 918+ shell via ssh (not chroot)
  2. sudo -u http php occ files:scan --all (or any command - even config)

The output of your Nextcloud log in Admin > Logging:

A bunch of these but from when I was setting up the system - no errors for this issue above...

{"reqId":"uJMm2pzIhqAp9BKjewAZ","level":3,"time":"2018-12-06T04:37:49+00:00","remoteAddr":"192.168.1.20","user":"--","app":"PHP","method":"GET","url":"\/nextcloud\/index.php\/login","message":"PHP Startup: No such handler: DBA_DEFAULT at Unknown#0","userAgent":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.110 Safari\/537.36","version":"14.0.4.2"}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'ocza2g5zjcd7',
  'passwordsalt' => '*******',
  'secret' => '*****',
  'trusted_domains' => 
  array (
    0 => '192.168.1.50',
  ),
  'datadirectory' => '/volume1/nextcloud',
  'dbtype' => 'mysql',
  'version' => '14.0.4.2',
  'overwrite.cli.url' => 'http://192.168.1.50/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => '127.0.0.1:3307',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => '****',
  'dbpassword' => '****',
  'installed' => true,
);

The output of your Apache/nginx/system log in /var/log/____:

2018/12/07 13:54:21 [error] 22515#22515: *95211 upstream prematurely closed connection while reading upstream, client: 192.168.1.20, server: _, request: "GET /nextcloud/ocs/v2.php/core/navigation/apps?absolute=true&format=json HTTP/1.1", upstream: "http://127.0.0.1:915/nextcloud/ocs/v2.php/core/navigation/apps?$
2018/12/07 14:22:58 [error] 22515#22515: *97267 upstream prematurely closed connection while reading upstream, client: 192.168.1.20, server: _, request: "GET /nextcloud/ocs/v2.php/core/navigation/apps?absolute=true&format=json HTTP/1.1", upstream: "http://127.0.0.1:915/nextcloud/ocs/v2.php/core/navigation/apps?$
2018/12/07 14:23:08 [error] 22516#22516: *97697 upstream prematurely closed connection while reading upstream, client: 192.168.1.20, server: _, request: "GET /nextcloud/ocs/v2.php/core/navigation/apps?absolute=true&format=json HTTP/1.1", upstream: "http://127.0.0.1:915/nextcloud/ocs/v2.php/core/navigation/apps?$
2018/12/07 14:24:06 [error] 22517#22517: *97038 upstream prematurely closed connection while reading upstream, client: 192.168.1.20, server: _, request: "GET /nextcloud/ocs/v2.php/core/navigation/apps?absolute=true&format=json HTTP/1.1", upstream: "http://127.0.0.1:915/nextcloud/ocs/v2.php/core/navigation/apps?$
2018/12/07 14:25:09 [error] 22515#22515: *98225 upstream prematurely closed connection while reading upstream, client: 192.168.1.20, server: _, request: "GET /nextcloud/ocs/v2.php/core/navigation/apps?absolute=true&format=json HTTP/1.1", upstream: "http://127.0.0.1:915/nextcloud/ocs/v2.php/core/navigation/apps?$

Help? Please?

Hi, which web server are you running? Maybe executing “php” on cli starts a different/ differently configured php binary/ environment (bad wording :stuck_out_tongue:)?

Can you try to run:
sudo -u http php /volume1/web/nextcloud/occ

Same error messages?

Hi, thanks. so the synology needed the following magical command for which I was able to find one random posting which alluded to doing something like this. The command which I added to the tast system in control panel goes something like this.

sudo -u http php70 -c /volume1/web/php.ini /volume1/web/nextcloud/occ files:scan --all

So on the synology it allows for 5.6 and 70 php which the stock php points towards the 5.6, but the magic is in the php.ini file which needed to be put somewhere besides the nextcloud directory and accessible by this command so it can pass the DB parameters through.

Mark

1 Like

Hi Mark!
I have a similar problem like yours (OCC Error "could not find driver in /httpdocs/nextcloud/lib/private/DB/Connection.php:64") But my nextcloud is running on a hosted webserver and not on a synology.

Can you tell me, what you wrote in your php.ini?

Best regards,
Julian