Failed to connect to database after upgrade to Ubuntu 22.04.1 LTS (different sender)

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, 29.0.5): 25.013
Operating system and version (eg, Ubuntu 24.04): 22.04 Apache or nginx version _(eg, Apache 2.4.25)_: 2.4.52
PHP version (eg, 8.3): php8.1

The issue you are facing:
after updating Linux Ubuntu to 22.04 LTS,
Nextcloud is not starting. i get an error in the apache2 log:

[Thu Aug 29 14:01:44.054500 2024] [php7:error] [pid 1965910] [client 192.168.56.230:64792] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/nextcloud/lib/private/DB/Connection.php:139\nStack trace:\n#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\\DB\\Connection->connect()\n#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\\DBAL\\Connection->getWrappedConnection()\n#2 /var/www/nextcloud/lib/private/DB/Connection.php(261): Doctrine\\DBAL\\Connection->executeQuery()\n#3 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\\DB\\Connection->executeQuery()\n#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(281): Doctrine\\DBAL\\Query\\QueryBuilder->execute()\n#5 /var/www/nextcloud/lib/private/AppConfig.php(419): OC\\DB\\QueryBuilder\\QueryBuilder->execute()\n#6 /var/www/nextcloud/lib/private/AppConfig.php(184): OC\\AppConfig->loadConfigValues()\n#7 /var/www/nextcloud/lib/private/AppConfig.php(375): OC\\AppConfig->ge in /var/www/nextcloud/lib/private/DB/Connection.php on line 139

this error i got is similiar to this: Failed to connect to database after upgrade to Ubuntu 22.04.1 LTS
i’ve tried to do what based on that: a2enmod php8.1, but php8.1 is already enabled:

Considering dependency mpm_prefork for php8.1:
Considering conflict mpm_event for mpm_prefork:
Considering conflict mpm_worker for mpm_prefork:
Module mpm_prefork already enabled
Considering conflict php5 for php8.1:
Module php8.1 already enabled

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

Steps to replicate it:

The output of your Nextcloud log in Admin > Logging:

No nextcloud log

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

<?php
$CONFIG = array (
  'instanceid' => 'oc***REDACTED***',
  'passwordsalt' => '***REDACTED***',
  'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  'trusted_domains' => 
  array (
    0 => 'drive.xxx.com',
    1 => '192.168.45.9',
  ),
  0 => 
  array (
    0 => '192.168.45.9',
  ),
  'onlyoffice' => 
  array (
    'verify_peer_off' => true,
    'jwt_secret' => '***REDACTED***',
    'jwt_header' => 'AuthorizationJwt',
  ),
  'datadirectory' => '/mnt/nc/new-nc',
  'dbtype' => 'mysql',
  'version' => '25.0.13.2',
  'overwrite.cli.url' => 'http://192.168.45.9/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'ncuser',
  'dbpassword' => 'xxx',
  'installed' => true,
  'ldapIgnoreNamingRules' => false,
  'ldapProviderFactory' => 'OCA\\User_LDAP\\LDAPProviderFactory',
  'allow_local_remote_servers' => true,
  'mail_from_address' => 'nextcloud',
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => 'xxx.com',
  'mail_smtphost' => 'xxx',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtpport' => '25',
  'mail_smtpname' => 'nextcloud',
  'mail_smtppassword' => 'xxx',
  'updater.secret' => '***REDACTED***',
  'maintenance' => false,
  'theme' => '',
  'loglevel' => 2,
  'has_rebuilt_cache' => true,
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud/nextcloud/log',
  'updater.release.channel' => 'stable',
);

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

none

Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

[Thu Aug 29 14:01:44.054500 2024] [php7:error] [pid 1965910] [client 192.168.56.230:64792] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory in /var/www/nextcloud/lib/private/DB/Connection.php:139\nStack trace:\n#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1519): OC\\DB\\Connection->connect()\n#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1041): Doctrine\\DBAL\\Connection->getWrappedConnection()\n#2 /var/www/nextcloud/lib/private/DB/Connection.php(261): Doctrine\\DBAL\\Connection->executeQuery()\n#3 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(345): OC\\DB\\Connection->executeQuery()\n#4 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(281): Doctrine\\DBAL\\Query\\QueryBuilder->execute()\n#5 /var/www/nextcloud/lib/private/AppConfig.php(419): OC\\DB\\QueryBuilder\\QueryBuilder->execute()\n#6 /var/www/nextcloud/lib/private/AppConfig.php(184): OC\\AppConfig->loadConfigValues()\n#7 /var/www/nextcloud/lib/private/AppConfig.php(375): OC\\AppConfig->ge in /var/www/nextcloud/lib/private/DB/Connection.php on line 139`

thanks a lot.

What’s the status of your MySQL/MariaDB database server after upgrading Ubuntu? Are you sure it’s running?

Yes mariaDB is running well.
well after upgrading OS to 22.04 my php8.1 did not installed extensions for mysql. now it’s worked.

1 Like

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