PHP Fatal Error: Uncaught Doctrine\\DBAL\DBAL exception

Nextcloud version (eg, 10.0.2): 12.0.1.5
Operating system and version (eg, Ubuntu 16.04): Ubuntu 16.04 running as guest on Windows 7 host using Oracle VirtualBox
Apache or nginx version (eg, Apache 2.4.25): 2.4.18
PHP version (eg, 5.6): 7.0.22
Is this the first time you’ve seen this error?: Yes

Can you reliably replicate it? (If so, please outline steps): Attempt to open Nextcloud using https:///nextcloud. No screen is received and no browser message displayed. The errors show up in the apache2 error.log

The issue you are facing: Cannot open Nextcloud webserver after enabling SSL in apache2. The webserver was working before I enabled SSL. I’m using NAT with port forwarding to get from host IP 192.168.1.2:5180 to webserver IP 10.0.2.15:80. I noticed the NAT gateway address, 10.0.2.2 is also showing up in the nextcloud log and getting rejected. Not sure if that’s significant. The apache2 error.log is showing two messages that might be related.

AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name

[Tue Aug 15 10:17:10.056861 2017] [:error] [pid 1689] [client 10.0.2.15:50008] PHP Fatal error: Uncaught Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in …

I verified my server.csr uses 10.0.2.15 for the server name.

The output of my Nextcloud log in nextcloud.log
{“reqId”:“qMgL4prZPM5z8evMGfRp”,“level”:2,“time”:“2017-08-11T21:09:53+00:00”,“remoteAddr”:“10.0.2.2”,“user”:"–",“app”:“core”,“method”:“GET”,“url”:"/nextcloud/index.php",“message”:“Trusted domain error. “10.0.2.2” tried to access using “192.168.1.2:5180” as host.”,“userAgent”:“Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36”,“version”:“12.0.1.5”}
{“reqId”:“vheJPZbD0e8B2f2N3U4O”,“level”:2,“time”:“2017-08-11T21:09:53+00:00”,“remoteAddr”:“10.0.2.2”,“user”:"–",“app”:“core”,“method”:“GET”,“url”:"/nextcloud/index.php/js/core/merged-template-prepend.js?v=96e3bdabf3b6437eedce819310ea8bc5-0",“message”:“Trusted domain error. “10.0.2.2” tried to access using “192.168.1.2:5180” as host.”,“userAgent”:“Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36”,“version”:“12.0.1.5”}
{“reqId”:“SsAT8Au0V6v31K00jDm3”,“level”:2,“time”:“2017-08-11T21:11:10+00:00”,“remoteAddr”:“10.0.2.2”,“user”:"–",“app”:“core”,“method”:“GET”,“url”:"/nextcloud/index.php",“message”:“Trusted domain error. “10.0.2.2” tried to access using “192.168.1.2:5180” as host.”,“userAgent”:“Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36”,“version”:“12.0.1.5”}
{“reqId”:“A2uBc0ttueHzPjHxIWVX”,“level”:2,“time”:“2017-08-11T21:11:10+00:00”,“remoteAddr”:“10.0.2.2”,“user”:"–",“app”:“core”,“method”:“GET”,“url”:"/nextcloud/index.php/js/core/merged-template-prepend.js?v=96e3bdabf3b6437eedce819310ea8bc5-0",“message”:“Trusted domain error. “10.0.2.2” tried to access using “192.168.1.2:5180” as host.”,“userAgent”:“Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36”,“version”:“12.0.1.5”}
{“reqId”:“qGKEm29s5UB14s6K20GD”,“level”:2,“time”:“2017-08-11T21:11:11+00:00”,“remoteAddr”:“10.0.2.2”,“user”:"–",“app”:“core”,“method”:“GET”,“url”:"/nextcloud/index.php/js/core/merged-template-prepend.js?v=96e3bdabf3b6437eedce819310ea8bc5-0",“message”:“Trusted domain error. “10.0.2.2” tried to access using “192.168.1.2:5180” as host.”,“userAgent”:“Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36”,“version”:“12.0.1.5”}
{“reqId”:“0tdH1nsXV1igBGO7jSOu”,“level”:2,“time”:“2017-08-11T21:23:06+00:00”,“remoteAddr”:“10.0.2.2”,“user”:"–",“app”:“core”,“method”:“GET”,“url”:"/nextcloud/index.php",“message”:“Trusted domain error. “10.0.2.2” tried to access using “192.168.1.2:5180” as host.”,“userAgent”:“Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36”,“version”:“12.0.1.5”}
{“reqId”:“eRk8lcoTsfgcFAtLQgBL”,“level”:2,“time”:“2017-08-11T21:23:06+00:00”,“remoteAddr”:“10.0.2.2”,“user”:"–",“app”:“core”,“method”:“GET”,“url”:"/nextcloud/index.php/js/core/merged-template-prepend.js?v=96e3bdabf3b6437eedce819310ea8bc5-0",“message”:“Trusted domain error. “10.0.2.2” tried to access using “192.168.1.2:5180” as host.”,“userAgent”:“Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36”,“version”:“12.0.1.5”}
{“reqId”:“zdhKKa1jL2PL56YxRMcb”,“level”:2,“time”:“2017-08-11T21:31:17+00:00”,“remoteAddr”:“10.0.2.2”,“user”:"–",“app”:“core”,“method”:“GET”,“url”:"/nextcloud/index.php",“message”:“Trusted domain error. “10.0.2.2” tried to access using “192.168.1.2:5180” as host.”,“userAgent”:“Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36”,“version”:“12.0.1.5”}
{“reqId”:“sJjVYqibwp4VxtDFyqQW”,“level”:2,“time”:“2017-08-11T21:31:17+00:00”,“remoteAddr”:“10.0.2.2”,“user”:"–",“app”:“core”,“method”:“GET”,“url”:"/nextcloud/index.php/js/core/merged-template-prepend.js?v=96e3bdabf3b6437eedce819310ea8bc5-0",“message”:“Trusted domain error. “10.0.2.2” tried to access using “192.168.1.2:5180” as host.”,“userAgent”:“Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36”,“version”:“12.0.1.5”}
{“reqId”:“XlmfQFu7YpqRBLzdeErR”,“level”:2,“time”:“2017-08-13T21:38:48+00:00”,“remoteAddr”:“10.0.2.15”,“user”:"–",“app”:“core”,“method”:“POST”,“url”:"/index.php/login",“message”:“Login failed: ‘admin’ (Remote IP: ‘10.0.2.15’)”,“userAgent”:“Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0”,“version”:“12.0.1.5”}
{“reqId”:“kxFYZZVaO8CPtR9pru5p”,“level”:2,“time”:“2017-08-13T21:39:05+00:00”,“remoteAddr”:“10.0.2.15”,“user”:"–",“app”:“core”,“method”:“POST”,“url”:"/index.php/login?user=admin",“message”:“Login failed: ‘admin’ (Remote IP: ‘10.0.2.15’)”,“userAgent”:“Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0”,“version”:“12.0.1.5”}

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

<?php $CONFIG = array ( 'instanceid' => 'oc0b7a8mpb9t', 'passwordsalt' => '0CHz+alWfUzMVZDuFgt0RRaTCarC1m', 'secret' => '2O5RB3e8F7JajAfq7Px6PLwg6SbRUpvBSxKZ1RZf/oP/loHS', 'trusted_domains' => array ( 0 => '10.0.2.15', 1 => '192.168.1.2:5180', ), 'datadirectory' => '/var/www/html/nextcloud/data', 'overwrite.cli.url' => 'http://10.0.2.15', 'dbtype' => 'mysql', 'version' => '12.0.1.5', 'dbname' => 'ncdatam', 'dbhost' => 'localhost', 'dbport' => '', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'cekcloud', 'dbpassword' => 'xxxxx', 'installed' => true, ); The output of my Apache/nginx/system log in `/var/log/____`: [Tue Aug 15 07:35:04.800985 2017] [ssl:warn] [pid 30849] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name [Tue Aug 15 07:35:04.801096 2017] [mpm_prefork:notice] [pid 30849] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations [Tue Aug 15 07:35:04.801102 2017] [core:notice] [pid 30849] AH00094: Command line: '/usr/sbin/apache2' [Tue Aug 15 08:37:33.239521 2017] [mpm_prefork:notice] [pid 30849] AH00169: caught SIGTERM, shutting down [Tue Aug 15 08:38:30.629184 2017] [ssl:warn] [pid 1533] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name [Tue Aug 15 08:38:34.724413 2017] [ssl:warn] [pid 1535] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name [Tue Aug 15 08:38:34.733232 2017] [mpm_prefork:notice] [pid 1535] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations [Tue Aug 15 08:38:34.733285 2017] [core:notice] [pid 1535] AH00094: Command line: '/usr/sbin/apache2' [Tue Aug 15 09:00:22.600121 2017] [mpm_prefork:notice] [pid 1535] AH00169: caught SIGTERM, shutting down [Tue Aug 15 09:01:17.890786 2017] [ssl:warn] [pid 1663] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name [Tue Aug 15 09:01:22.222421 2017] [ssl:warn] [pid 1664] AH01909: localhost:443:0 server certificate does NOT include an ID which matches the server name [Tue Aug 15 09:01:22.227988 2017] [mpm_prefork:notice] [pid 1664] AH00163: Apache/2.4.18 (Ubuntu) OpenSSL/1.0.2g configured -- resuming normal operations [Tue Aug 15 09:01:22.228045 2017] [core:notice] [pid 1664] AH00094: Command line: '/usr/sbin/apache2' [Tue Aug 15 10:17:10.056861 2017] [:error] [pid 1689] [client 10.0.2.15:50008] PHP Fatal error: Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/html/nextcloud/lib/private/DB/Connection.php:61\nStack trace:\n#0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /var/www/html/nextcloud/lib/private/DB/Connection.php(148): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\\DB\\Connection->__construct(Array, Object(Doctrin in /var/www/html/nextcloud/lib/private/DB/Connection.php on line 61, referer: https://10.0.2.15/nextcloud/ [Tue Aug 15 10:17:10.057188 2017] [:error] [pid 1689] [client 10.0.2.15:50008] PHP Fatal error: Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/html/nextcloud/lib/private/DB/Connection.php:61\nStack trace:\n#0 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /var/www/html/nextcloud/lib/private/DB/Connection.php(148): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php(172): OC\\DB\\Connection->__construct(Array, Object(Doctrin in /var/www/html/nextcloud/lib/private/DB/Connection.php on line 61, referer: https://10.0.2.15/nextcloud/