Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com 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:

example

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

longer
example
here

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 14.0.3
Operating system and version Ubuntu 16.04
Apache or nginx version Apache/2.4.18 (Ubuntu)
PHP version (eg, 7.1): PHP 7.0.32-0ubuntu0.16.04.1 (cli) ( NTS )

The issue you are facing:

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

Steps to replicate it:

  1. Restart Nextcloud
  2. Check logs

The output of your Nextcloud log in Admin > Logging:

|Error|cron|Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory|2018-11-13T14:34:44-0500|
|---|---|---|---|
|Error|core|Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory|2018-11-13T14:34:44-0500|
|Error|files|Doctrine\DBAL\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] No such file or directory|2018-11-13T14:34:44-0500|
|Error|files|RedisException: read error on connection|2018-11-13T14:34:44-0500|
|Error|PHP|Error while sending QUERY packet. PID=15323 at /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php#1297|2018-11-13T14:34:44-0500|
|Error|core|Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'SELECT `id`, `numeric_id`, `available`, `last_checked` FROM `oc_storages` WHERE `id` IN (?)' with params ["local::\/var\/www\/html\/nextcloud\/data\/"]: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away|2018-11-13T14:34:44-0500|
|Error|core|Doctrine\DBAL\Exception\DriverException: An exception occurred while executing 'SELECT `id`, `numeric_id`, `available`, `last_checked` FROM `oc_storages` WHERE `id` IN (?)' with params ["smb::nextcloud@192.168.139.5\/\/nextcloud\/\/"]: SQLSTATE[08S01]: Communication link failure: 1053 Server shutdown in progress|2018-11-13T14:34:44-0500|
|Error|PHP|Error while sending QUERY packet. PID=16186 at /var/www/html/nextcloud/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php#105|2018-11-13T14:34:44-0500|

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

{
    "system": {
        "instanceid": "***REMOVED SENSITIVE VALUE***",
        "passwordsalt": "***REMOVED SENSITIVE VALUE***",
        "secret": "***REMOVED SENSITIVE VALUE***",
        "trusted_domains": [
            "192.168.139.107"
        ],
        "datadirectory": "***REMOVED SENSITIVE VALUE***",
        "overwrite.cli.url": "http:\/\/192.168.139.107\/nextcloud",
        "dbtype": "mysql",
        "version": "14.0.3.0",
        "dbname": "***REMOVED SENSITIVE VALUE***",
        "dbhost": "***REMOVED SENSITIVE VALUE***",
        "dbport": "",
        "dbtableprefix": "oc_",
        "mysql.utf8mb4": true,
        "dbuser": "***REMOVED SENSITIVE VALUE***",
        "dbpassword": "***REMOVED SENSITIVE VALUE***",
        "installed": true,
        "htaccess.RewriteBase": "\/nextcloud",
        "memcache.local": "\\OC\\Memcache\\APCu",
        "memcache.locking": "\\OC\\Memcache\\Redis",
        "trashbin_retention_obligation": "10, 15",
        "filelocking.enabled": "true",
        "redis": {
            "host": "***REMOVED SENSITIVE VALUE***",
            "port": 0,
            "timeout": 0
        },
        "maintenance": false,
        "theme": "",
        "loglevel": 2,
        "mail_smtpmode": "smtp",
        "mail_smtpauthtype": "LOGIN",
        "mail_smtpauth": 1,
        "mail_smtphost": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpport": "465",
        "mail_domain": "***REMOVED SENSITIVE VALUE***",
        "mail_smtpsecure": "ssl",
        "mail_smtpname": "***REMOVED SENSITIVE VALUE***",
        "mail_smtppassword": "***REMOVED SENSITIVE VALUE***"
    }
}

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

[Tue Nov 13 06:25:02.379741 2018] [mpm_prefork:notice] [pid 1375] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Tue Nov 13 06:25:02.379759 2018] [core:notice] [pid 1375] AH00094: Command line: '/usr/sbin/apache2'
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
[Tue Nov 13 14:12:48.789785 2018] [autoindex:error] [pid 15323] [client 192.168.139.47:59631] AH01276: Cannot serve directory /var/www/html/nextcloud: No matching DirectoryIndex (n$
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
[Tue Nov 13 14:12:54.428012 2018] [authz_core:error] [pid 15618] [client 192.168.139.47:59637] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 14:12:56.741549 2018] [authz_core:error] [pid 5401] [client 192.168.139.47:59636] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 14:13:01.158360 2018] [authz_core:error] [pid 16313] [client 192.168.139.47:59641] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 14:27:28.858857 2018] [autoindex:error] [pid 16186] [client 192.168.139.47:60281] AH01276: Cannot serve directory /var/www/html/nextcloud: No matching DirectoryIndex (n$
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
[Tue Nov 13 14:27:33.971393 2018] [authz_core:error] [pid 16313] [client 192.168.139.47:60286] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 14:27:36.050220 2018] [authz_core:error] [pid 16313] [client 192.168.139.47:60286] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 14:27:53.486698 2018] [authz_core:error] [pid 5399] [client 192.168.139.47:60293] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 14:27:59.098264 2018] [authz_core:error] [pid 16313] [client 192.168.139.47:60295] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 14:34:44.876363 2018] [mpm_prefork:notice] [pid 1375] AH00169: caught SIGTERM, shutting down
[Tue Nov 13 14:35:22.162538 2018] [mpm_prefork:notice] [pid 1386] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Tue Nov 13 14:35:22.178620 2018] [core:notice] [pid 1386] AH00094: Command line: '/usr/sbin/apache2'
[Tue Nov 13 14:35:35.225775 2018] [authz_core:error] [pid 1422] [client 192.168.139.47:60402] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 14:37:05.515673 2018] [authz_core:error] [pid 1450] [client 192.168.139.47:60426] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 14:37:16.932886 2018] [authz_core:error] [pid 1539] [client 192.168.139.47:60435] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 14:38:36.723950 2018] [authz_core:error] [pid 1549] [client 192.168.139.47:60442] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 14:39:22.947426 2018] [authz_core:error] [pid 1549] [client 192.168.139.47:60458] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
[Tue Nov 13 16:52:56.783612 2018] [autoindex:error] [pid 3455] [client 192.168.139.47:61645] AH01276: Cannot serve directory /var/www/html/nextcloud: No matching DirectoryIndex (no$
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
[Tue Nov 13 16:53:02.519859 2018] [authz_core:error] [pid 3677] [client 192.168.139.47:61649] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 16:53:05.497970 2018] [authz_core:error] [pid 14886] [client 192.168.139.47:61648] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 16:53:10.237484 2018] [authz_core:error] [pid 3451] [client 192.168.139.47:61652] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 16:53:19.726701 2018] [authz_core:error] [pid 14701] [client 192.168.139.47:61655] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 16:59:51.047668 2018] [mpm_prefork:notice] [pid 1386] AH00169: caught SIGTERM, shutting down
[Tue Nov 13 17:00:24.127058 2018] [mpm_prefork:notice] [pid 1385] AH00163: Apache/2.4.18 (Ubuntu) configured -- resuming normal operations
[Tue Nov 13 17:00:24.258487 2018] [core:notice] [pid 1385] AH00094: Command line: '/usr/sbin/apache2'
[Tue Nov 13 17:02:46.930234 2018] [autoindex:error] [pid 1416] [client 192.168.139.47:61762] AH01276: Cannot serve directory /var/www/html/nextcloud: No matching DirectoryIndex (no$
mkdir failed on directory /var/run/samba/msg.lock: Permission denied
[Tue Nov 13 17:03:02.492346 2018] [authz_core:error] [pid 1543] [client 192.168.139.47:61767] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 17:03:04.471880 2018] [authz_core:error] [pid 1543] [client 192.168.139.47:61767] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata
[Tue Nov 13 17:03:09.789544 2018] [authz_core:error] [pid 1419] [client 192.168.139.47:61765] AH01630: client denied by server configuration: /var/www/html/nextcloud/data/.ocdata