An issue with upgrade from Ubuntu 20.04 to Ubuntu 22.04 - NC 25.0.6

[/details]
Nextcloud version (eg, 20.0.5): 25.0.6
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.41 (Ubuntu)
PHP version (eg, 7.4): PHP 7.4.3-4ubuntu2.18

After upgrade from Ubuntu 20.04 to 22.04

Nextcloud version (eg, 20.0.5): 25.0.6
Operating system and version (eg, Ubuntu 20.04): Ubuntu 22.04
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.52 (Ubuntu)
PHP version (eg, 7.4): PHP 8.1.2-1ubuntu2.11
The issue you are facing:
I upgraded the virtual private server from Ubuntu 20.04 LTS to 22.04 LTS. After the upgrade my NC stopped working. I am getting an error:

This site can’t be reached

nextcloud.abc.eu refused to connect.

Try:

ERR_CONNECTION_REFUSED

Could you help me how to do a proper upgrade from Ubuntu 20.04 to Ubuntu 22.04 where Nextcloud 25.0.6 is installed?
My main reason for the upgrade is that I would like to upgrade PHP from 7.4 to PHP 8.1. PHP 7.4 has been out of support since November 2022.

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

Steps to replicate it:

  1. upgrade from Ubuntu 20.04 to Ubuntu 22.04

The output of your Nextcloud log in Admin > Logging: No access to GUI

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

nextcloud/config/config.php

<?php
$CONFIG = array (
  'instanceid' => 'ABC',
  'passwordsalt' => 'ABC',
  'secret' => 'ABC',
  'trusted_domains' =>
  array (
    0 => 'abc.eu',
  ),
  'datadirectory' => '/mnt/nfsko/nextcloud_data',
  'dbtype' => 'mysql',
  'version' => '25.0.6.1',
  'overwrite.cli.url' => 'https://abc.eu',
  'dbname' => 'abc',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'abc,
  'dbpassword' => 'abc',
  'installed' => true,
  'default_phone_region' => 'DE',
  'maintenance' => false,
  'loglevel' => 0,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_from_address' => 'abc.d',
  'mail_smtpsecure' => 'tls',
  'mail_domain' => 'abc.com',
  'mail_smtphost' => 'smtp.abc.com',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'abc.d',
  'mail_smtppassword' => 'abc',
  'has_rebuilt_cache' => true,
  'app_install_overwrite' =>
  array (
    0 => 'files_external_dropbox',
    1 => 'files_ebookreader',
    2 => 'apporder',
    3 => 'breezedark',
    4 => 'duplicatefinder',
    5 => 'electronicsignatures',
    6 => 'extract',
    7 => 'impersonate',
  ),
  'updater.release.channel' => 'stable',
  'opcache.interned_strings_buffer' => 220,
  'theme' => '',
  'memcache.local' => '\\OC\\Memcache\\APCu',
);```

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

/var/log/apache2/nextcloud_error.log


[Sun Apr 30 20:15:44.654208 2023] [access_compat:error] [pid 335] [client 94.218.11.87:53160] AH01797: client denied by server configuration: /var/www/nextcloud/config
[Sun Apr 30 20:33:57.712302 2023] [php7:error] [pid 1855] [client 94.218.11.87:53414] 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
[Sun Apr 30 20:34:05.714664 2023] [php7:error] [pid 6981] [client 94.218.11.87:53416] 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
[Sun Apr 30 20:34:24.715151 2023] [php7:error] [pid 1857] [client 94.218.11.87:53418] 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
/var/log/apache2/nextcloud_access.log

[30/Apr/2023:20:33:04 +0200] "PROPFIND /remote.php/dav/files/janvozar/ HTTP/1.1" 207 238
[30/Apr/2023:20:33:06 +0200] "GET /ocs/v2.php/core/navigation/apps?absolute=true&format=json HTTP/1.1" 304 -
[30/Apr/2023:20:33:13 +0200] "PROPFIND /remote.php/dav/files/janvozar/ HTTP/1.1" 207 250
[30/Apr/2023:20:33:34 +0200] "PROPFIND /remote.php/dav/files/janvozar/ HTTP/1.1" 500 289
[30/Apr/2023:20:33:57 +0200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 500 -
[30/Apr/2023:20:34:04 +0200] "PROPFIND /remote.php/dav/files/janvozar/ HTTP/1.1" 500 289
[30/Apr/2023:20:34:05 +0200] "GET /ocs/v2.php/apps/notifications/api/v2/notifications?format=json HTTP/1.1" 500 -
[30/Apr/2023:20:34:24 +0200] "PUT /ocs/v2.php/apps/user_status/api/v1/heartbeat?format=json HTTP/1.1" 500 -
[30/Apr/2023:20:34:34 +0200] "PROPFIND /remote.php/dav/files/janvozar/ HTTP/1.1" 500 289
[30/Apr/2023:20:35:04 +0200] "PROPFIND /remote.php/dav/files/janvozar/ HTTP/1.1" 500 289```

Can you check if your database is running?
Looks like there is no connection possible.
I had a similar error from 18.04 to 20.04 with AppArmor and MariaDB. But its (somehow) solved now.

MariaDB is running. See below.

$ sudo service mysql status
● mariadb.service - MariaDB 10.6.12 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2023-04-30 22:54:55 CEST; 1min 42s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 264 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 291 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`cd /usr/bin/..; /usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
    Process: 361 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 363 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 334 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 10 (limit: 629145)
     Memory: 82.9M
     CGroup: /system.slice/mariadb.service
             └─334 /usr/sbin/mariadbd

Apr 30 22:54:55 abc mariadbd[334]: 2023-04-30 22:54:55 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
Apr 30 22:54:55 abc mariadbd[334]: 2023-04-30 22:54:55 0 [Note] InnoDB: 10.6.12 started; log sequence number 31376712216; transaction id 97232150
Apr 30 22:54:55 abc mariadbd[334]: 2023-04-30 22:54:55 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Apr 30 22:54:55 abc mariadbd[334]: 2023-04-30 22:54:55 0 [Note] Plugin 'FEEDBACK' is disabled.
Apr 30 22:54:55 abc mariadbd[334]: 2023-04-30 22:54:55 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
Apr 30 22:54:55 abc mariadbd[334]: 2023-04-30 22:54:55 0 [Note] Server socket created on IP: '127.0.0.1'.
Apr 30 22:54:55 abc mariadbd[334]: 2023-04-30 22:54:55 0 [Note] /usr/sbin/mariadbd: ready for connections.
Apr 30 22:54:55 abc mariadbd[334]: Version: '10.6.12-MariaDB-0ubuntu0.22.04.1'  socket: '/run/mysqld/mysqld.sock'  port: 3306  Ubuntu 22.04
Apr 30 22:54:55 abc systemd[1]: Started MariaDB 10.6.12 database server.
Apr 30 22:54:55 abc mariadbd[334]: 2023-04-30 22:54:55 0 [Note] InnoDB: Buffer pool(s) load completed at 230430 22:54:55

$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.2 LTS
Release:	22.04
Codename:	jammy

Wish I could help but I’m really following to learn. I everytime I’ve tried to upgrade Ubuntu from 20 to 22, I have issues and I’m sure it is the PHP upgrade. I’ve tried just upgrading PHP 7.4 to 8.1 while staying on Ubuntu 20 and still have issues. I built a test server from scratch with Ubuntu 22/PHP 8.1 and things are great but I’m looking to upgrade my production server without breaking the instance. Any documented steps pertaining to doing this for Nextcloud would be so helpful.

Did you try to upgrade PHP 7.4 to 8.1 first and then to do the upgrade to Ubuntu 22.04?
Are you using do-release-upgrade or working with a manual way (changing sources.lists and then doing dist-upgrades)?
Any other services running on this server?

Did you try to upgrade PHP 7.4 to 8.1 first and then to do the upgrade to Ubuntu 22.04?
I can try to do a separate update for PHP from the extra repository because PHP 8.1 is not available at Ubuntu 20.04

Are you using do-release-upgrade or working with a manual way (changing sources.lists and then doing dist-upgrades)?
I am using do-release-upgrade

Any other services running on this server?
No, this server is dedicated to Nextcloud

With the manual update of php to 8.1 you could check if it is somehow the handler which is nkt working or if there’s anything else wrong.
Another log you could check is the nextcloud log in the data directory. Maybe there’s some hint why its not loading.
Sometimes it could also be a permission problem. Did yoj check that they are correct?

  1. do-release-upgrade
  2. Once done, reinstall PHP and it’s dependencies
  3. Profit
1 Like

Let’s see what versions of php things are really installed:

dpkg -l | grep php

I suspect you’ve got old stuff and new stuff mingled.

You’re likely going to have to do some porting of your php and apache configurations as well. But let’s get the modules sorted out first.