Doctrine\DBAL\Exception: Exception Failed to connect to the database: An exception occurred in the driver: could not find driver

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face: is for home/non-enterprise users. If you’re running a business, paid support can be accessed via where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:


Or for longer, use three backticks above and below the code snippet:


Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version: 28.0.1
Operating system and version: Debian 11 (oldstable)
Apache version: 2.4.56-1~deb11u1
PHP version: 8.2.14-1+0~20231221.38+debian11~1.gbp698136 (via Sury PPA repository)

The issue you are facing:
Since 2024-01-09 the log of my private nextcloud instance is flooded with the following error messages:
Error|cron|Exception Failed to connect to the database: An exception occurred in the driver: could not find driver|Exception thrown: Doctrine\DBAL\Exception

Origin is the nextcloud cron job running every five minutes. I can replicate the error by manually executing: sudo -u www-data php occ

My nextcloud installation has been kept stable since 2023-12-21 (upgrade to version 28.0.1), the corresponding nextcloud configuration has been kept stable for at least half a year. My overall server configuration has not been touched for at least a month. Exceptions to the above: regular debian system and nextcloud app maintenance updates.

Apart from that the nextcloud instance seems to run as normal.

I am a bit puzzled about the sudden emergence of this error on an otherwise stable configuration. The only reason I can think of are the above maintenance updates that I execute on a regular basis (and that I might not have paid enough attention to lately).

And I am a bit puzzled about the next steps that I could take to tackle this issue. Has anybody experienced the same or a comparable issue lately? Or could somebody at least point me into the right direction for solving this issue, e.g. how can I track down the driver that “could not be found”?

Thanks in advance!

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

Steps to replicate it:

  1. Wait for Nextcloud cron Job run (every 5 minutes)
  2. Alternatively execute manually: sudo -u www-data php occ

The output of your Nextcloud log in Admin > Logging:

Error|cron|Exception Failed to connect to the database: An exception occurred in the driver: could not find driver|Exception thrown: Doctrine\DBAL\Exception

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

$CONFIG = array (
  'passwordsalt' => 'xxx',
  'secret' => 'xxx',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => '',
    2 => '',
    3 => '',
  'datadirectory' => 'xxx',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => 'http://localhost',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nc_admin',
  'dbpassword' => 'xxx',
  'installed' => true,
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => 'localhost',
    'port' => 6379,
    'timeout' => 0.0,
  'filelocking.enabled' => true,
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/var/www/nextcloud/apps',
      'url' => '/apps',
      'writable' => false,
    1 => 
    array (
      'path' => '/var/www/nextcloud/apps-3rdparty',
      'url' => '/apps-3rdparty',
      'writable' => true,
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => '\\OCA\\User_LDAP\\LDAPProviderFactory',
  'maintenance' => false,
  'loglevel' => 2,
  'defaultapp' => 'apporder',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'instanceid' => 'xxx',
  'mail_from_address' => 'xxx',
  'mail_smtphost' => '',
  'mail_smtpport' => 'xxx',
  'mail_domain' => '',
  'theme' => '',
  'app_install_overwrite' => 
  array (
    0 => 'passwords',
    1 => 'orcid',
    2 => 'files_mindmap',
    3 => 'apporder',
  'default_phone_region' => 'xx',
  'data-fingerprint' => 'xxx',
  'mail_smtpsecure' => 'tls',
  'mail_smtpauthtype' => 'PLAIN',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'xxx',
  'mail_smtppassword' => 'xxx

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

{"reqId":"7y3diKLCjbOFejyzyaR0","level":3,"time":"2024-01-13T08:40:01+00:00","remoteAddr":"","user":"--","app":"cron","method":"","url":"--","message":"Exception thrown: Doctrine\\DBAL\\Exception","userAgent":"--","version":"","exception":{"Exception":"Doctrine\\DBAL\\Exception","Message":"Failed to connect to the database: An exception occurred in the driver: could not find driver","Code":0,"Trace":[{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1654,"function":"connect","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php","line":1081,"function":"getWrappedConnection","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/Connection.php","line":261,"function":"executeQuery","class":"Doctrine\\DBAL\\Connection","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":337,"function":"executeQuery","class":"OC\\DB\\Connection","type":"->"},{"file":"/var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php","line":377,"function":"executeQuery","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->"},{"file":"/var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php","line":280,"function":"execute","class":"Doctrine\\DBAL\\Query\\QueryBuilder","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppConfig.php","line":418,"function":"execute","class":"OC\\DB\\QueryBuilder\\QueryBuilder","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppConfig.php","line":184,"function":"loadConfigValues","class":"OC\\AppConfig","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppConfig.php","line":374,"function":"getApps","class":"OC\\AppConfig","type":"->"},{"file":"/var/www/nextcloud/lib/private/App/AppManager.php","line":128,"function":"getValues","class":"OC\\AppConfig","type":"->"},{"file":"/var/www/nextcloud/lib/private/App/AppManager.php","line":149,"function":"getInstalledAppsValues","class":"OC\\App\\AppManager","type":"->"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_App.php","line":231,"function":"getInstalledApps","class":"OC\\App\\AppManager","type":"->"},{"file":"/var/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php","line":90,"function":"getEnabledApps","class":"OC_App","type":"::"},{"file":"/var/www/nextcloud/lib/base.php","line":700,"function":"runInitialRegistration","class":"OC\\AppFramework\\Bootstrap\\Coordinator","type":"->"},{"file":"/var/www/nextcloud/lib/base.php","line":1200,"function":"init","class":"OC","type":"::"},{"file":"/var/www/nextcloud/cron.php","line":43,"args":["/var/www/nextcloud/lib/base.php"],"function":"require_once"}],"File":"/var/www/nextcloud/lib/private/DB/Connection.php","Line":139,"CustomMessage":"Exception thrown: Doctrine\\DBAL\\Exception"},"id":"65a24cdc0a1c3"}```
1 Like

I successfully solved my above issue. So, if anybody runs into similar issues here’s what I found out:

As already suspected, a regular debian system maintenance update (in conjunction with the Sury PPA repository) has been the source of my problems: Though having explicitly installed PHP 8.2 via the Sury PPA repository, 4 days ago the following new packages were installed during a regular system update: php8.3-common, php8.3-readline, php8.3-opcache, php8.3-cli, php8.3-fpm. (It seems that the (unnecessarily installed) dependency package php-fpm triggered the installation of the new package version.)

This explains the symptoms I experienced:

  • On command line level (including cron jobs), the update installed PHP 8.3 as the new default version leading to errors.
  • On Apache level however, PHP 8.2 remained the only configured version keeping system operations normal.

After removing the above packages, my issues disappeared.

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.