Internal Server Error after Proxmox Snaptshot Backup (Update to Ubuntu 22, NC 24 and PHP 8.1)

Nextcloud version (eg, 20.0.5): 24.0.4
Operating system and version (eg, Ubuntu 20.04): Ubuntu 22.04.1 LTS
Apache or nginx version (eg, Apache 2.4.25): Apache/2.4.52 (Ubuntu)
PHP version (eg, 7.4): 8.1.2

The issue you are facing:

I run three NextCloud instances. All three were running without any problems. I then updated from Ubuntu 20 to Ubuntu 22 and Nextcloud 23 to Nextcloud 24. Since then, all three instances have been crashing at irregular intervals. I have not found a way to provoke the crashes.

As soon as I try to access Nextcloud via an explorer I get the following error message:

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

The desktop clients will not be able to synchronize either. It helps to restart the server, then everything works again for an indefinite time. I really hope that someone can help me to fix the error. Thank you very much for your time.

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

Steps to replicate it:

  1. Restart the server
  2. Wait for an indefinite time
  3. Server crashes

The output of your Nextcloud log in Admin > Logging:

Error	PHP	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away at /var/www/html/3rdparty/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php#101	
	2022-08-17T12:50:10+0200
Fatal	webdav	Sabre\DAV\Exception\ServiceUnavailable: OC\DB\Exceptions\DbalException: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:10+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:08+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200
Error	cron	Doctrine\DBAL\Exception\ConnectionLost: An exception occurred while executing a query: SQLSTATE[HY000]: General error: 2006 MySQL server has gone away	
2022-08-17T12:50:07+0200

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

<?php
$CONFIG = array (
  'instanceid' => 'XXXXX',
  'passwordsalt' => 'XXXXX',
  'secret' => 'XXXXX',
  'trusted_domains' => 
  array (
    0 => 'XXXXX',
  ),
  'datadirectory' => '/mnt/data',
  'dbtype' => 'mysql',
  'version' => '24.0.4.1',
  'overwrite.cli.url' => 'XXXXX',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextclouduser',
  'dbpassword' => 'XXXXX',
  'installed' => true,
  'simpleSignUpLink.shown' => false,
  'default_phone_region' => 'DE',
  'htaccess.RewriteBase' => '/',
  'maintenance' => false,
  'theme' => '',
  'log_type' => 'file',
  'logtimezone' => 'Europe/Berlin',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'loglevel' => 2,
  'syslog_tag' => 'Nextcloud',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauth' => 1,
  'mail_sendmailmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_from_address' => 'info',
  'mail_domain' => 'XXXXX',
  'mail_smtphost' => 'XXXXX',
  'mail_smtpport' => '465',
  'mail_smtpname' => 'XXXXX',
  'mail_smtppassword' => 'XXXXX',
  'updater.release.channel' => 'stable',
  'app_install_overwrite' => 
  array (
    0 => 'richdocumentscode',
    1 => 'documentserver_community',
    2 => 'backup',
  ),
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => 'true',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'trusted_proxies' => 
  array (
    0 => 'XXXXX',
  ),
  'overwritehost' => 'XXXXX',
  'overwriteprotocol' => 'https',
);

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

[Wed Aug 17 00:00:02.019309 2022] [mpm_prefork:notice] [pid 182] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed Aug 17 00:00:02.019511 2022] [core:notice] [pid 182] AH00094: Command line: '/usr/sbin/apache2'
[Wed Aug 17 04:32:55.450368 2022] [mpm_prefork:notice] [pid 182] AH00171: Graceful restart requested, doing restart
[Wed Aug 17 04:32:55.512321 2022] [mpm_prefork:notice] [pid 182] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed Aug 17 04:32:55.512425 2022] [core:notice] [pid 182] AH00094: Command line: '/usr/sbin/apache2'
[Wed Aug 17 04:32:59.943258 2022] [mpm_prefork:notice] [pid 182] AH00171: Graceful restart requested, doing restart
[Wed Aug 17 04:32:59.971623 2022] [mpm_prefork:notice] [pid 182] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed Aug 17 04:32:59.971636 2022] [core:notice] [pid 182] AH00094: Command line: '/usr/sbin/apache2'
[Wed Aug 17 12:50:23.910091 2022] [php:error] [pid 10339] [client 113.208.212.54:55210] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection >
[Wed Aug 17 14:47:39.679656 2022] [php:error] [pid 9593] [client 113.208.212.54:55248] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection r>
[Wed Aug 17 14:47:39.679655 2022] [php:error] [pid 10335] [client 113.208.212.54:55250] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection >
[Wed Aug 17 14:47:39.681821 2022] [php:error] [pid 9595] [client 113.208.212.54:55254] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection r>
[Wed Aug 17 14:47:39.682682 2022] [php:error] [pid 9601] [client 113.208.212.54:55252] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection r>
[Wed Aug 17 18:50:02.192652 2022] [php:error] [pid 9601] [client 113.208.212.54:55352] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection r>
[Wed Aug 17 19:32:07.989746 2022] [php:error] [pid 10335] [client 113.208.212.54:55364] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection >
[Wed Aug 17 19:32:08.031265 2022] [php:error] [pid 9595] [client 113.208.212.54:55368] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection r>
[Wed Aug 17 19:32:08.077279 2022] [php:error] [pid 9601] [client 113.208.212.54:55370] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection r>
[Wed Aug 17 21:34:41.336694 2022] [mpm_prefork:notice] [pid 182] AH00171: Graceful restart requested, doing restart
[Wed Aug 17 21:34:41.487447 2022] [mpm_prefork:notice] [pid 182] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed Aug 17 21:34:41.487715 2022] [core:notice] [pid 182] AH00094: Command line: '/usr/sbin/apache2'
[Wed Aug 17 21:34:48.916255 2022] [mpm_prefork:notice] [pid 182] AH00171: Graceful restart requested, doing restart
[Wed Aug 17 21:34:48.955802 2022] [mpm_prefork:notice] [pid 182] AH00163: Apache/2.4.52 (Ubuntu) OpenSSL/3.0.2 configured -- resuming normal operations
[Wed Aug 17 21:34:48.955816 2022] [core:notice] [pid 182] AH00094: Command line: '/usr/sbin/apache2'
[Wed Aug 17 23:08:38.770310 2022] [php:error] [pid 14057] [client 113.208.212.54:55474] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection >
[Wed Aug 17 23:08:38.773378 2022] [php:error] [pid 14059] [client 113.208.212.54:55480] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection >
[Wed Aug 17 23:08:38.773411 2022] [php:error] [pid 14055] [client 113.208.212.54:55478] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection >
[Wed Aug 17 23:30:19.672928 2022] [php:error] [pid 14057] [client 113.208.212.54:55494] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection >
[Wed Aug 17 23:30:19.672936 2022] [php:error] [pid 14056] [client 113.208.212.54:55496] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection >
[Wed Aug 17 23:30:21.784795 2022] [php:error] [pid 14059] [client 113.208.212.54:55498] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection >
[Wed Aug 17 23:30:21.805900 2022] [php:error] [pid 14055] [client 113.208.212.54:55500] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection >
[Wed Aug 17 23:30:21.805905 2022] [php:error] [pid 14058] [client 113.208.212.54:55502] PHP Fatal error:  Uncaught Doctrine\\DBAL\\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] Connection >
[Thu Aug 18 00:00:01.508247 2022] [mpm_prefork:notice] [pid 182] AH00171: Graceful restart requested, doing restart

Because of the errors i think it could be a problem with your database. Maybe you can search in this direction. Read the logs of your database e.g. MariaDB.

Thanks for yor reply. Ich checked the mysql error log. Nothing new there. The last entry is from the 27.05.2022.

I’m also having issues with nextcloud 24 after upgrading to Ubuntu 22.04. It seems to be related to mysql somehow. But wasn’t able to find any specific errors (apache/php/mysql). I’ve rolled back to Ubuntu 20.04 for now and will further investigate on a cloned vm.
Before upgrading I did test everything on a test instance without any issues. Strange.

It annoys me the most that I can’t find a specific bug or provoke the crashes by a specific behavior. They seem to occur randomly.

I have so far removed and reinstalled all PHP modules, reassigned all folder permissions, and reset database permissions in MariaDB. All to no success. I would be very happy to hear of any other approaches.

@Bauanga is your nextcloud running on bare-metal or as vm e. g. on proxmox?

In a lxc container on proxmox

php 8.1 is not yet supported.
If you can add 8.0 setup all the extensions necessary and make your nextcloud run under 8.0, it should bring back to life.

@Ark74 While you are right that PHP8.0 is still the recommanded version, PHP8.1 is supported and in most cases Nextcloud 24 is runing perfectly fine with it.

@Bauanga Your php setup is probably missing some modules. Is php-mysql installed? You can check by entering php -m on the command line…

@Ark74 If a rollback to php8.0 helps, i will do that defintily.

@bb77 My Nextcloud Instances are up and running, then they are crashing from time to time. After a restart everthing is up again for an uncertain amount of time. Like this, the use in a productive environment is impossible. Shouldn’t a missing PHP plugin prevent the operation completely? Here is the output of php -m:

root@nextcloud:/var/log/mysql# php -m
[PHP Modules]
apcu
bcmath
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
igbinary
imagick
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
sockets
sodium
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

Yeah you’re right. Unfortunatly the error messages are pretty generic. They are basically just saying that no connection to the database could be established. A few (also very generic) things that come to mind, that coud cause this…

  • Server too busy (very high RAM or CPU usage).
  • A problem with the PHP setup
  • A problem with the database itself
  • A problem with the storage on which the database is running

I would probably start with reinstalling PHP and if the error still occurs, check on the database itself. However I’m not a database expert and therefore I can’t give you any specific advice from the top of my head…

I think I found the trigger for the problem, but not the cause. The NextCloud instances are running via Proxmox in an LXC container. Once a week the containers are backed up via snapshot to a Proxmox backup server. I have not looked at this process as there have never been any problems with it. When the backup is triggered, the Nextcloud is timing out. Then the memory fills up until it is full. Then the Nextcloud crashes and I get the internal server error. This new behavior is timed right after the update to Ubuntu 22, NC 24 and PHP8.1. Whether there is a direct correlation with the update, or something wrong with the backup process on proxmox I can’t say. Also not which process is responsible for it.

I have set the backup mode to stop. Even if the downtimes are bigger, I have no more crashes this way.

This does not seem to be directly related to LXC, but qemu.
There’s a thread about this at proxmox forum wich also links to the related bug reports:

@Bauanga maybe you can double check whether this does match your issue.