# An exception occurred in the driver: could not find driver in /var/www/html/lib/private/DB/Connection.php:142

**URL:** <https://help.nextcloud.com/t/an-exception-occurred-in-the-driver-could-not-find-driver-in-var-www-html-lib-private-db-connection-php-142/161877>\
**Category:** ℹ️ Support\
**Created:** [May 11, 2023, 12:04am UTC](https://help.nextcloud.com/t/an-exception-occurred-in-the-driver-could-not-find-driver-in-var-www-html-lib-private-db-connection-php-142/161877 "2023-05-11T00:04:12Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![theaddies](https://help.nextcloud.com/letter_avatar/theaddies/32/6_449c533f586939b6e5f246632a46421f.png) [@theaddies](https://help.nextcloud.com/u/theaddies)\
**Post date:** [May 11, 2023, 12:04am UTC](https://help.nextcloud.com/t/an-exception-occurred-in-the-driver-could-not-find-driver-in-var-www-html-lib-private-db-connection-php-142/161877/1 "2023-05-11T00:04:12Z")

</div>

I am trying to upgrade from version 25 to 26. I have a stand alone installation on an ubuntu server. It was running php7.4 and when running

sudo -u www-data php occ upgrade

It required I upgrade to php8.0. I did that. Now I get this error below.

> Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: could not find driver in /var/www/html/lib/private/DB/Connection.php:142  
> Stack trace:  
> #0 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1531): OC\DB\Connection-\>connect()  
> #1 /var/www/html/3rdparty/doctrine/dbal/src/Connection.php(1029): Doctrine\DBAL\Connection-\>getWrappedConnection()  
> #2 /var/www/html/lib/private/DB/Connection.php(264): Doctrine\DBAL\Connection-\>executeQuery()  
> #3 /var/www/html/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\DB\Connection-\>executeQuery()  
> #4 /var/www/html/lib/private/DB/QueryBuilder/QueryBuilder.php(280): Doctrine\DBAL\Query\QueryBuilder-\>execute()  
> #5 /var/www/html/lib/private/AppConfig.php(418): OC\DB\QueryBuilder\QueryBuilder-\>execute()  
> #6 /var/www/html/lib/private/AppConfig.php(184): OC\AppConfig-\>loadConfigValues()  
> #7 /var/www/html/lib/private/AppConfig.php(374): OC\AppConfig-\>getApps()  
> #8 /var/www/html/lib/private/legacy/OC\_App.php(976): OC\AppConfig-\>getValues()  
> #9 /var/www/html/lib/private/Server.php(729): OC\_App::getAppVersions()  
> #10 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server-\>OC{closure}()  
> #11 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer-\>OC\AppFramework\Utility{closure}()  
> #12 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container-\>offsetGet()  
> #13 /var/www/html/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer-\>query()  
> #14 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer-\>query()  
> #15 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(193): OC\AppFramework\Utility\SimpleContainer-\>get()  
> #16 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\AppFramework\Utility\SimpleContainer-\>OC\AppFramework\Utility{closure}()  
> #17 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer-\>OC\AppFramework\Utility{closure}()  
> #18 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container-\>offsetGet()  
> #19 /var/www/html/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer-\>query()  
> #20 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer-\>query()  
> #21 /var/www/html/lib/private/Server.php(1110): OC\AppFramework\Utility\SimpleContainer-\>get()  
> #22 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server-\>OC{closure}()  
> #23 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer-\>OC\AppFramework\Utility{closure}()  
> #24 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container-\>offsetGet()  
> #25 /var/www/html/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer-\>query()  
> #26 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer-\>query()  
> #27 /var/www/html/lib/private/Server.php(2065): OC\AppFramework\Utility\SimpleContainer-\>get()  
> #28 /var/www/html/lib/private/Files/View.php(119): OC\Server-\>getLockingProvider()  
> #29 /var/www/html/lib/private/Server.php(464): OC\Files\View-\>\_\_construct()  
> #30 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(171): OC\Server-\>OC{closure}()  
> #31 /var/www/html/3rdparty/pimple/pimple/src/Pimple/Container.php(122): OC\AppFramework\Utility\SimpleContainer-\>OC\AppFramework\Utility{closure}()  
> #32 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(138): Pimple\Container-\>offsetGet()  
> #33 /var/www/html/lib/private/ServerContainer.php(171): OC\AppFramework\Utility\SimpleContainer-\>query()  
> #34 /var/www/html/lib/private/AppFramework/Utility/SimpleContainer.php(65): OC\ServerContainer-\>query()  
> #35 /var/www/html/lib/private/Server.php(1467): OC\AppFramework\Utility\SimpleContainer-\>get()  
> #36 /var/www/html/lib/base.php(623): OC\Server-\>boot()  
> #37 /var/www/html/lib/base.php(1165): OC::init()  
> #38 /var/www/html/console.php(48): require\_once(‘…’)  
> #39 /var/www/html/occ(11): require\_once(‘…’)

---

<div class="post-metadata">

**Author:** ![jtr](https://help.nextcloud.com/letter_avatar/jtr/32/6_449c533f586939b6e5f246632a46421f.png) [@jtr](https://help.nextcloud.com/u/jtr)\
**Post date:** [May 11, 2023, 12:13am UTC](https://help.nextcloud.com/t/an-exception-occurred-in-the-driver-could-not-find-driver-in-var-www-html-lib-private-db-connection-php-142/161877/2 "2023-05-11T00:13:19Z")

</div>

When you upgrade php, make sure you also install all the required php extensions for the upgraded version. The Ubuntu specific instructions might be useful:

[https://docs.nextcloud.com/server/stable/admin\_manual/installation/example\_ubuntu.html](https://docs.nextcloud.com/server/stable/admin_manual/installation/example_ubuntu.html)

The full module list is here just in case:

[https://docs.nextcloud.com/server/stable/admin\_manual/installation/source\_installation.html#prerequisites-for-manual-installation](https://docs.nextcloud.com/server/stable/admin_manual/installation/source_installation.html#prerequisites-for-manual-installation)

I suspect that error is because you’re missing the one for your database, but you’re likely also missing the rest if you upgraded.

---

<div class="post-metadata">

**Author:** ![theaddies](https://help.nextcloud.com/letter_avatar/theaddies/32/6_449c533f586939b6e5f246632a46421f.png) [@theaddies](https://help.nextcloud.com/u/theaddies)\
**Post date:** [May 11, 2023, 12:44am UTC](https://help.nextcloud.com/t/an-exception-occurred-in-the-driver-could-not-find-driver-in-var-www-html-lib-private-db-connection-php-142/161877/3 "2023-05-11T00:44:06Z")

</div>

Thanks for the reply. I think I am doomed. I just don’t have enough knowledge to know what to do. I have been running nextcloud for years and love it. I have upgraded many times. I was at least on version 19 a long time ago. I ran the commands below but I get this error now.

OCP\HintException: [0]: Memcache OC\Memcache\APCu not available for local cache (Is the matching PHP module installed and enabled?)

sudo apt install apache2 mariadb-server libapache2-mod-php php-gd php-mysql   
php-curl php-mbstring php-intl php-gmp php-bcmath php-xml php-imagick php-zip

---

<div class="post-metadata">

**Author:** ![theaddies](https://help.nextcloud.com/letter_avatar/theaddies/32/6_449c533f586939b6e5f246632a46421f.png) [@theaddies](https://help.nextcloud.com/u/theaddies)\
**Post date:** [May 11, 2023, 12:49am UTC](https://help.nextcloud.com/t/an-exception-occurred-in-the-driver-could-not-find-driver-in-var-www-html-lib-private-db-connection-php-142/161877/4 "2023-05-11T00:49:30Z")

</div>

I should also add that I looked in /etc/php/8.0/mods-available/ and there is no apcu.ini file. It is present in /etc/php/7.4/mods-available. I upgraded from 7.4 to 8.0

---

<div class="post-metadata">

**Author:** ![theaddies](https://help.nextcloud.com/letter_avatar/theaddies/32/6_449c533f586939b6e5f246632a46421f.png) [@theaddies](https://help.nextcloud.com/u/theaddies)\
**Post date:** [May 11, 2023, 11:16am UTC](https://help.nextcloud.com/t/an-exception-occurred-in-the-driver-could-not-find-driver-in-var-www-html-lib-private-db-connection-php-142/161877/5 "2023-05-11T11:16:41Z")

</div>

I ended up getting it to work. First I had to run  
apt install php8.0-apcu.  
Then I added  
apc.enable\_cli = 1  
to the file  
/etc/php/8.x/mods-available/apcu.ini

---

<div class="post-metadata">

**Author:** ![ernolf](https://help.nextcloud.com/user_avatar/help.nextcloud.com/ernolf/32/77874_2.png) [@ernolf](https://help.nextcloud.com/u/ernolf)\
**Post date:** [May 11, 2023, 11:42am UTC](https://help.nextcloud.com/t/an-exception-occurred-in-the-driver-could-not-find-driver-in-var-www-html-lib-private-db-connection-php-142/161877/6 "2023-05-11T11:42:10Z")

</div>

> [@theaddies](#):
>
> sudo apt install apache2 mariadb-server libapache2-mod-php php-gd php-mysql  
> php-curl php-mbstring php-intl php-gmp php-bcmath php-xml php-imagick php-zip

> [@theaddies](#):
>
> I just don’t have enough knowledge to know what to do.

I wrote a script for safe php upgrade on Ubuntu with apache2.

The script works if the following requirements are met:

1. The old php version (7.4) must still be fully installed.  
This condition is met if you have not yet explicitly uninstalled (with --purge) any old php7.4 packages.
2. There must be no incomplete PHP installation of the new version.  
In your case it looks like not all [pecl packages](https://pecl.php.net/) needed by your installation are installed. Therefore, if 1. is met, the already installed php8.0 packages should be removed first:

```sh
sudo apt-get remove --purge *php8.0*

```

If that is done, download the update-script:

```sh
sudo wget -qO /usr/local/bin/php-updater https://global-social.net/script/php-updater
sudo chmod +x /usr/local/bin/php-updater

```

execute the script simply by calling it:  
`sudo php-updater`  
it looks what php-version actually is installed and asks which new version you want to install. (First I would recommend 8.0). After the installation it migrates all settings from your old php-installation (_php.ini_ for _php-cli_ and _php-apache2_ or - in case you are using php-fpm - the php.ini for php-fpm and _pool.d/www.conf_ for php-fpm) into the new version.  
If you already have completely installed one or more new versions (e.g. 8.0 and 8.1), you can use the script for only the later step (the migration from all setting) by calling it  
`sudo php-updater 7.4 8.0`  
In this case, it would read the settings from your 7.4 Version and helps you to integrate them into the 8.0 version.

Run this command to control, if all php-versions are switched to the version you want. I would recommend to not leave it in automatic mode but choosing the respective manual mode so that no unintentional version changes can take place, but only after your conscious change (using this command):

```sh
for linkgroup in $(ls /var/lib/dpkg/alternatives/ | grep -E "ph(ar|p)"); do sudo update-alternatives --config $linkgroup; done

```

finaly change the used libapache2-mod-php in your apache server (if not yet done by installation routine):

```sh
sudo a2dismod php7.4
sudo a2enmod php8.0
sudo apachectl restart

```

After everything runs nice, you can remove all old php packages:

```sh
sudo apt-get remove --purge *php7.4*

```

Feel free to ask me anything you want prior to follow this steps

---

<div class="post-metadata">

**Author:** ![theaddies](https://help.nextcloud.com/letter_avatar/theaddies/32/6_449c533f586939b6e5f246632a46421f.png) [@theaddies](https://help.nextcloud.com/u/theaddies)\
**Post date:** [May 11, 2023, 11:40pm UTC](https://help.nextcloud.com/t/an-exception-occurred-in-the-driver-could-not-find-driver-in-var-www-html-lib-private-db-connection-php-142/161877/7 "2023-05-11T23:40:46Z")

</div>

Wow, thanks so much for the post. So everything seems to work fine without running the script. Should I still do it?

---

<div class="post-metadata">

**Author:** ![ernolf](https://help.nextcloud.com/user_avatar/help.nextcloud.com/ernolf/32/77874_2.png) [@ernolf](https://help.nextcloud.com/u/ernolf)\
**Post date:** [May 12, 2023, 8:44am UTC](https://help.nextcloud.com/t/an-exception-occurred-in-the-driver-could-not-find-driver-in-var-www-html-lib-private-db-connection-php-142/161877/8 "2023-05-12T08:44:49Z")

</div>

> [@theaddies](#):
>
> So everything seems to work fine without running the script. Should I still do it?

If everything seems to work fine, then you seem to have made the right steps all by yourself.

You can at least skip part 1 of the script (the update process) and only do the second step, just to align the settings from the old installation with the new one: `sudo php-updater 7.4 8.0` (assuming you updated to 8.0). You dont need to have any fear, it asks you before anny change would be made.

The step of switching the _update-alternatives_ version control to manual mode is definitely a good choice to avoid accidental version switches and -mismatches. The next time you update your php Version, you know what you have to do \[1\]. (Simply calling `sudo update-alternatives` basically does exactly the same, it then shows ALL the alternatives managed by this tool and not just the php-related ones. Just skip the alternatives you want to leave with “Enter”.)

Much luck!

* * *

* * *

1. For a future update, you can check if an updated version of the script is available, as I continue to develop it, adding new features from time to time. For example the update-alternatives switch, the automatic switch between libapache2-mod-php and php-fpm and back etc. and some analysis routines, to analyze errors or weak points to fix them in a dialog.

---

<div class="post-metadata">

**Author:** ![micranes](https://help.nextcloud.com/letter_avatar/micranes/32/6_449c533f586939b6e5f246632a46421f.png) [@micranes](https://help.nextcloud.com/u/micranes)\
**Post date:** [September 11, 2024, 3:40pm UTC](https://help.nextcloud.com/t/an-exception-occurred-in-the-driver-could-not-find-driver-in-var-www-html-lib-private-db-connection-php-142/161877/9 "2024-09-11T15:40:52Z")

</div>

That fixed it for me.

---

<div class="post-metadata">

**Author:** ![micranes](https://help.nextcloud.com/letter_avatar/micranes/32/6_449c533f586939b6e5f246632a46421f.png) [@micranes](https://help.nextcloud.com/u/micranes)\
**Post date:** [September 11, 2024, 3:40pm UTC](https://help.nextcloud.com/t/an-exception-occurred-in-the-driver-could-not-find-driver-in-var-www-html-lib-private-db-connection-php-142/161877/10 "2024-09-11T15:40:55Z")

</div>

Here are the changes. I accidentally hit enter and split my post up.  
date.timezone = Africa/Nairobi  
memory\_limit = 512M  
upload\_max\_filesize = 500M  
post\_max\_size = 500M  
max\_execution\_time = 300

---

<div class="post-metadata">

**Author:** ![micranes](https://help.nextcloud.com/letter_avatar/micranes/32/6_449c533f586939b6e5f246632a46421f.png) [@micranes](https://help.nextcloud.com/u/micranes)\
**Post date:** [September 11, 2024, 3:41pm UTC](https://help.nextcloud.com/t/an-exception-occurred-in-the-driver-could-not-find-driver-in-var-www-html-lib-private-db-connection-php-142/161877/11 "2024-09-11T15:41:07Z")

</div>

I had this same message and realized I forgot to make these settings changes in the PHP settings.

---

<div class="post-metadata">

**Author:** ![system](https://help.nextcloud.com/user_avatar/help.nextcloud.com/system/32/29333_2.png) [@system](https://help.nextcloud.com/u/system)\
**Post date:** [December 10, 2024, 3:41pm UTC](https://help.nextcloud.com/t/an-exception-occurred-in-the-driver-could-not-find-driver-in-var-www-html-lib-private-db-connection-php-142/161877/12 "2024-12-10T15:41:08Z")

</div>

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