Http 500, Failed to connect to the database, could not find driver

Nextcloud version: 29.05-1
Operating system and version: Manjaro 24.0.8
Apache version: 2.4.62-1
PHP version: 8.2.22

The issue you are facing:
New Nextcloud installation, getting 500 error from Apache when trying to connect to the webapp for the first time. Logs indicate that the db driver can’t be found. Checking other versions of this question, I’ve double checked that php’s pgsql packages are installed and enabled in my nextcloud/php.ini file. The apache server is up and has access to php (phpinfo()). The postgres server is up and can be connected to via cli. DB table shown below.

Is this the first time you’ve seen this error?: Y

Steps to replicate it:

  1. Install Manjaro
  2. Install Postgres
  3. Install PHP
  4. Install Apache
  5. Install Nextcloud
  6. Browse to http://localhost/nextcloud

The output of your Nextcloud log in Admin > Logging:

unreachable

The output of your config.php file in /path/to/nextcloud:

<?php
$CONFIG = array (
  'datadirectory' => '/var/lib/nextcloud/data',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'apps_paths' => 
  array (
    0 => 
    array (
      'path' => '/usr/share/webapps/nextcloud/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 => 
    array (
      'path' => '/var/lib/nextcloud/apps',
      'url' => '/wapps',
      'writable' => true,
    ),
  ),
  'trusted_domains' => 
  array (
          0 => 'localhost',
          1 => '192.168.1.1/32',
  ),
  'overwrite.cli.url' => 'https://192.168.1.101/nextcloud',
  'htaccess.RewriteBase' => '/',
  'passwordsalt' => '',
  'secret' => '',
  'dbtype' => 'pgsql',
  'version' => '29.0.5.1',
  'dbname' => 'nextcloud',
  'dbhost' => '/run/postgresql',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => '',
  'dbpassword' => '',
  'installed' => true,
  'instanceid' => '',
  'maintenance_window_start' => 6,
);

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

127.0.0.1 - - [18/Sep/2024:14:21:54 -0400] "GET /nextcloud/index.php HTTP/1.1" 500 289

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors.

{"reqId":"krNHfq2rD7SLHtnhFJA6","level":3,"time":"2024-09-18T18:21:54+00:00","remoteAddr":"127.0.0.1","user":"--","app":"core","method":"GET","url":"/nextcloud/index.php","message":"Exception thrown: Doctrine\\DBAL\\Exception","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:130.0) Gecko/20100101 Firefox/130.0","version":"29.0.5.1","exception":{"Exception":"Doctrine\\DBAL\\Exception","Message":"Failed to connect to the database: An exception occurred in the driver: could not find driver","Code":0

DB Tables

                                                         List of databases
   Name    |   Owner   | Encoding | Locale Provider |   Collate   |    Ctype    | ICU Locale | ICU Rules |    Access privileges    
-----------+-----------+----------+-----------------+-------------+-------------+------------+-----------+-------------------------
 nextcloud | nextcloud | UTF8     | libc            | C.UTF-8     | C.UTF-8     |            |           | nextcloud=CTc/nextcloud
 postgres  | postgres  | UTF8     | libc            | C.UTF-8     | C.UTF-8     |            |           | 
 template0 | postgres  | UTF8     | libc            | C.UTF-8     | C.UTF-8     |            |           | =c/postgres            +
           |           |          |                 |             |             |            |           | postgres=CTc/postgres
 template1 | postgres  | UTF8     | libc            | C.UTF-8     | C.UTF-8     |            |           | =c/postgres            +
           |           |          |                 |             |             |            |           | postgres=CTc/postgres

hello @gurahl welcome to the forum :handshake:

please review the docs and double check you installed all prerequisites, especially PHP modules

I solved the issue.

Per the instructions, I had created separate php.ini files for each application. Unfortunately, Nextcloud didn’t seem to be using the php.ini file that I set up for it. So I enabled the pgsql module in my main php.ini file and was able to connect.

Thanks!

I’ve been over the docs a few times and it seems like I have all the php modules installed. Do you have any recommendations for confirming the database driver module is working independently? I’m not a PHP pro and haven’t found much from searching online.

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