No more database connection after reboot

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 (eg, 12.0.2): 15.0.2
Operating system and version (eg, Ubuntu 17.04): Docker
Apache or nginx version (eg, Apache 2.4.25): Apache 2
PHP version (eg, 7.1): 7.2.14

The issue you are facing:

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

Steps to replicate it:

  1. have working nextcloud setup with external mysql database
  2. restart host computer

The output of your Nextcloud log in Admin > Logging:

[Thu Mar 07 17:04:32.939414 2019] [php7:error] [pid 34] [client 10.10.10.3:21620] PHP Fatal error:  Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] Connection timed out in /var/www/html/lib/private/DB/Connection.php:64\nStack trace:\n#0 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /var/www/html/lib/private/DB/Connection.php(151): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /var/www/html/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 in /var/www/html/lib/private/DB/Connection.php on line 64,
[Thu Mar 07 17:04:33.483929 2019] [php7:error] [pid 36] [client 10.10.10.3:21621] PHP Fatal error:  Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] Connection timed out in /var/www/html/lib/private/DB/Connection.php:64\nStack trace:\n#0 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /var/www/html/lib/private/DB/Connection.php(151): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /var/www/html/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 in /var/www/html/lib/private/DB/Connection.php on line 64,
10.10.10.3 - ***** [07/Mar/2019:17:02:33 +0000] "GET /ocs/v2.php/apps/notifications/api/v2/notifications?format=json HTTP/1.1" 500 211 "-" "Mozilla/5.0 (Windows) mirall/2.5.1final (build 20181204) (Nextcloud)",
[Thu Mar 07 17:04:34.887842 2019] [php7:error] [pid 87] [client 10.10.10.3:21570] PHP Fatal error:  Uncaught Doctrine\\DBAL\\DBALException: Failed to connect to the database: An exception occured in driver: SQLSTATE[HY000] [2002] Connection timed out in /var/www/html/lib/private/DB/Connection.php:64\nStack trace:\n#0 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(429): OC\\DB\\Connection->connect()\n#1 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(389): Doctrine\\DBAL\\Connection->getDatabasePlatformVersion()\n#2 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(328): Doctrine\\DBAL\\Connection->detectDatabasePlatform()\n#3 /var/www/html/3rdparty/doctrine/dbal/lib/Doctrine/DBAL/Connection.php(623): Doctrine\\DBAL\\Connection->getDatabasePlatform()\n#4 /var/www/html/lib/private/DB/Connection.php(151): Doctrine\\DBAL\\Connection->setTransactionIsolation(2)\n#5 /var/www/html/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 in /var/www/html/lib/private/DB/Connection.php on line 64,
10.10.10.3 - ***** [07/Mar/2019:17:02:04 +0000] "GET /status.php HTTP/1.1" 500 0 "-" "Mozilla/5.0 (Windows) mirall/2.5.1final (build 20181204) (Nextcloud)"

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

<?php
$CONFIG = array (
  'htaccess.RewriteBase' => '/',
  'trusted_domains' =>
  array (
    0 => 'X.X.X.55:8080',
  ),
  'trusted proxies' =>
  array (
    0 => 'X.X.X.3',
  ),
  'mail_smtpdebug' => 'true',
  'overwritewebroot' => '/',
  'overwritehost' => '*****',
  'overwriteprotocol' => 'https',
  'overwritecondaddr' => '^X\\.X\\.X\\.3$',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'apps_paths' =>
  array (
    0 =>
    array (
      'path' => '/var/www/html/apps',
      'url' => '/apps',
      'writable' => false,
    ),
    1 =>
    array (
      'path' => '/var/www/html/custom_apps',
      'url' => '/custom_apps',
      'writable' => true,
    ),
  ),
  'datadirectory' => '/var/www/html/data',
  'dbtype' => 'mysql',
  'version' => '15.0.2.0',
  'overwrite.cli.url' => 'http://X.X.X.55:8080',
  'installed' => true,
  'mysql.utf8mb4' => true,
  'maintenance' => false,
  'dbname' => 'nextcloud',
  'dbhost' => 'X.X.X.55:3306',
  'dbuser' => 'nextcloud',
  'dbpassword' => '*****',
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => '*****',
  'mail_from_address' => '*****',
  'mail_domain' => '*****',
  'mail_smtphost' => '*****',
  'mail_smtpport' => '25',
);

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

No apache log files exist

I just realized I forgot to post the problem i was encountering so I will add it here:
i had nextcloud installed and running in docker. Everything was working i was able to sync files and get into the web portal. I had to shutdown the Nextcloud host for some maintenance and when i brought the server and the container back up i was no longer able to sync files or access the web portal. The log files i have posted are from portainer and portainer is currently the only way to access the shell on the nextcloud installation

This is usually not a problem caused by Nextcloud. Make sure that your database is running, that the database can be accessed correctly and that the PHP database driver is correctly loaded.

You can check the database connectivity with any tool from bash, another pc or php cli.

i can connect to the DB with phpMyAdmin just fine, when attempting to connect to the db with telnet i get this weird string of characters and then a minute or so later it disconnects me.dbcon

Fixed. See

1 Like