HTTP 500 after upgrade from 12.0.5 to 13.0.0

Nextcloud version: 13.0.0
Operating system and version: Arch Linux
Apache or nginx version: Apache 2.4.29
PHP version: 7.1.14

My issue is almost identical to the one posted by commander here. However, when I run occ upgrade as recommended in the comments there I encounter a fatal PHP error:

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 /usr/share/webapps/nextcloud/lib/private/DB/Connection.php:64
Stack trace:
#0 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
#1 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /usr/share/webapps/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /usr/share/webapps/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 /usr/share/webapps/nextcloud/lib/private/DB/ConnectionFactory.php(152): Doctrine\DBAL\DriverManager::getConnection(Array, Object(Doctrine\DBAL\Configuration), Object(Doctrine\Common\EventManager))
#7 /usr/share/webapps/nextcloud/lib/private/Server.php(618): OC\DB\ConnectionFactory->getConnection('mysql', Array)
#8 /usr/share/webapps/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#9 /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OCP\\IDBConnecti...')
#10 /usr/share/webapps/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OCP\\IDBConnecti...')
#11 /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query('OCP\\IDBConnecti...')
#12 /usr/share/webapps/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#13 /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('DatabaseConnect...')
#14 /usr/share/webapps/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('DatabaseConnect...')
#15 /usr/share/webapps/nextcloud/lib/private/Server.php(1490): OC\ServerContainer->query('DatabaseConnect...')
#16 /usr/share/webapps/nextcloud/lib/private/Server.php(331): OC\Server->getDatabaseConnection()
#17 /usr/share/webapps/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#18 /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OC\\Authenticati...')
#19 /usr/share/webapps/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#20 /usr/share/webapps/nextcloud/lib/private/Server.php(335): OC\ServerContainer->query('OC\\Authenticati...')
#21 /usr/share/webapps/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#22 /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OC\\Authenticati...')
#23 /usr/share/webapps/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#24 /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query('OC\\Authenticati...')
#25 /usr/share/webapps/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#26 /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OC\\Authenticati...')
#27 /usr/share/webapps/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\Authenticati...')
#28 /usr/share/webapps/nextcloud/lib/private/Server.php(351): OC\ServerContainer->query('OC\\Authenticati...')
#29 /usr/share/webapps/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#30 /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OCP\\IUserSessio...')
#31 /usr/share/webapps/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OCP\\IUserSessio...')
#32 /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query('OCP\\IUserSessio...')
#33 /usr/share/webapps/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#34 /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('UserSession')
#35 /usr/share/webapps/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('UserSession')
#36 /usr/share/webapps/nextcloud/lib/private/Server.php(1359): OC\ServerContainer->query('UserSession')
#37 /usr/share/webapps/nextcloud/lib/private/Server.php(678): OC\Server->getUserSession()
#38 /usr/share/webapps/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(113): OC\Server->OC\{closure}(Object(OC\Server))
#39 /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('OC\\App\\AppManag...')
#40 /usr/share/webapps/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('OC\\App\\AppManag...')
#41 /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(164): OC\ServerContainer->query('OC\\App\\AppManag...')
#42 /usr/share/webapps/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(109): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}(Object(OC\Server))
#43 /usr/share/webapps/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): Pimple\Container->offsetGet('AppManager')
#44 /usr/share/webapps/nextcloud/lib/private/ServerContainer.php(132): OC\AppFramework\Utility\SimpleContainer->query('AppManager')
#45 /usr/share/webapps/nextcloud/lib/private/Server.php(1663): OC\ServerContainer->query('AppManager')
#46 /usr/share/webapps/nextcloud/lib/private/legacy/app.php(330): OC\Server->getAppManager()
#47 /usr/share/webapps/nextcloud/lib/private/legacy/app.php(113): OC_App::getEnabledApps()
#48 /usr/share/webapps/nextcloud/lib/base.php(661): OC_App::loadApps(Array)
#49 /usr/share/webapps/nextcloud/lib/base.php(1080): OC::init()
#50 /usr/share/webapps/nextcloud/console.php(46): require_once('/usr/share/weba...')
#51 /usr/share/webapps/nextcloud/occ(11): require_once('/usr/share/weba...')
#52 {main}

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

<?php
$CONFIG = array (
  'instanceid' => REDACTED,
  'passwordsalt' => REDACTED,
  'secret' => REDACTED,
  'trusted_domains' =>
  array (
    0 => REDACTED,
    1 => REDACTED,
  ),
  'datadirectory' => '/usr/share/webapps/nextcloud/data',
  'overwrite.cli.url' => REDACTED,
  'dbtype' => 'mysql',
  'version' => '12.0.4.3',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => REDACTED,
  'logtimezone' => 'UTC',
  'installed' => true,
  'theme' => '',
  'loglevel' => 2,
  'maintenance' => false,
);

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

PHP Fatal error:  Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /usr/share/webapps/nextcloud/lib/private/DB/Connection.php:64\nStack trace:\n#0 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /usr/share/webapps/nextcloud/lib/private/DB/Connection.php(151): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\\DB\\Connection->__construct(Array, Object in /usr/share/webapps/nextcloud/lib/private/DB/Connection.php on line 64

I made some progress, but I’m still having the same issue with nothing but blank pages with HTTP 500 errors.
I was able to fix the error when running occ upgrade by adding the following line to my php.ini:
extension=pdo_mysql.so
This exposed a different error:
PHP module GD not installed. Please ask your server administrator to install the module.
I was able to fix this error by adding the following line to my php.ini:
extension=gd.so
Then I could run occ upgrade successfully:

$ sudo -u http php occ upgrade
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Set log level to debug
Turned on maintenance mode
Updating database schema
Updated database
Disabled incompatible app: files_retention
...
Starting code integrity check...
Finished code integrity check
Update successful
Turned off maintenance mode
Reset log level

Now it seems I have a successfully upgraded instance of Nextcloud 13:

$ sudo -u http php occ upgrade
Nextcloud is already latest version

However, as I mentioned, I still just get blank HTTP 500 pages when I try to access it via the browser. The following message still shows up in my Apache error logs:

PHP Fatal error:  Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: could not find driver in /usr/share/webapps/nextcloud/lib/private/DB/Connection.php:64
Stack trace:
#0 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\DB\Connection->connect()
#1 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /usr/share/webapps/nextcloud/lib/private/DB/Connection.php(151): Doctrine\DBAL\Connection->setTransactionIsolation(2)
#5 /usr/share/webapps/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\DB\Connection->__construct(Array, Object in /usr/share/webapps/nextcloud/lib/private/DB/Connection.php on line 64

Have you tried to increase the value for idle-timeout for php-fpm?
Look in your apache.conf for the line starting with FastCgiExternalServer
and add the following to the options: -idle-timeout 250
I also had a problem with Error 500 and this worked.

I don’t have php-fpm installed and my httpd.conf doesn’t have a line with FastCgiExternalServer. Thanks for the suggestion though.

The line is in the site setup file for my nextcloud. But every distro handles their setup a bit differently.
If you don’t have php-fpm, perhaps you can try one of the other timeout values for apache, like this one:
http://httpd.apache.org/docs/2.2/mod/core.html#keepalivetimeout
I had a working setup before, but after upgrading to NC13 I had a few 500 type errors. I changed that value and the errors went away. I have other sites on the same server that don’t need that change and don’t give me 500 type errors.

Well, I tried setting KeepAliveTimeout to 250 and restarting Apache, but that didn’t change anything. Based on the message in the logs I don’t think it’s a timeout issue in my case, but a failure to connect to MariaDB.

It seems I’m not the only one who encountered this issue on Arch Linux.
I’m noticing these messages in the error log when I restart Apache that I think may be the culprit.

AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
PHP Warning:  PHP Startup: curl: Unable to initialize module
Module compiled with module API=20160303
PHP    compiled with module API=20170718
These options need to match
 in Unknown on line 0
PHP Warning:  PHP Startup: gd: Unable to initialize module
Module compiled with module API=20160303
PHP    compiled with module API=20170718
These options need to match
 in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'pdo_mysql.so' (tried: /usr/lib/php/modules/pdo_mysql.so (/usr/lib/php/modules/pdo_mysql.so: undefined symbol: strpprintf), /usr/lib/php/modules/pdo_mysql.so.so (/usr/lib/php/modules/pdo_mysql.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library 'zip.so' (tried: /usr/lib/php/modules/zip.so (/usr/lib/php/modules/zip.so: undefined symbol: spprintf), /usr/lib/php/modules/zip.so.so (/usr/lib/php/modules/zip.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0

It looks like there’s some sort of mismatch between the version of PHP and the installed modules that’s causing them to fail to load on startup.

Yes, this looks like a version mismatch. I don’t know about Arch, is there a mechanism in the package manager to check for dependencies?

which php version are you coming from?
I had a similar problem once.

I solved it usind the command: sudo -u http php7.1 occ upgrade.

If this is working, keep in mind that you’ll have to use php7.1 instead of php when running any occ command.

Hope this helps

But if you have multiple php versions installed you also have to tell your http daemon which one to use for your vhost. I found the approach described in the following article very useful to use either php5.6 or php7 on different vhosts:
https://pehapkari.cz/blog/2017/03/27/multiple-php-versions-the-easy-way/

Thanks for the suggestions. It turns out my problem was actually that I was using php 7.1. Nextcloud 12 depended on the package php71 and for some reason my package manager updated to Nextcloud 13 without updating me to the package php despite the dependency change. I’m not sure how that happened.

I fixed my problem by doing:

# pacman -S php-gd
# pacman -S php

Then I just had to uncomment the following lines in my php.ini once again:

extension=gd
extension=pdo_mysql

Then once I restarted Apache everything was working again. Thanks for all the help!