Internal Server Error, Nextcloud 22.0.0.11

Hi everybody,

My Cloud is not running since yesterday due to a constant “internal server error”. I`m researching the net since yesterday. Nothing helped - also not a post from 2018 in this forum. The error occurred after a backup trail (borg) with MariaDB dump.

Environment:
Ubuntu Server 20.04.2
MariaDB: 10.5.11
nginx: 1.21.1
php :7.4
redis: 5:5.0.7-2
smbd: 4.11.6-Ubuntu
coturn: 4.5.1.1-1.1ubuntu0.20.04.2
status off all: active, without error messages

Nextcloud: 22.0.0.11

This message is shown, when putting the cloud into maintenance mode:
Next Doctrine\DBAL\Exception\TableNotFoundException: An exception occurred while executing a query: SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘nextcloud_db.oc_appconfig’ doesn’t exist in /var/www/nextcloud/3rdparty/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:47

Is this the first time you’ve seen this error? In this context: yes

Steps to replicate it: Internal Server error is a constant error. The cloud doesn`t work, even if everything seems to be in Order

  1. sudo -u www-data php occ maintenance:mode --on

The output of your Nextcloud log in Admin > Logging: nothing,

Any tipps, links…I’m at a loss

Best & Cheers Jo

Details of report:

Stack trace:
#0 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1728): Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert()
#1 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1667): Doctrine\DBAL\Connection->handleDriverException()
#2 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(1040): Doctrine\DBAL\Connection->convertExceptionDuringQuery()
#3 /var/www/nextcloud/lib/private/DB/Connection.php(231): Doctrine\DBAL\Connection->executeQuery()
#4 /var/www/nextcloud/3rdparty/doctrine/dbal/src/Query/QueryBuilder.php(210): OC\DB\Connection->executeQuery()
#5 /var/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(287): Doctrine\DBAL\Query\QueryBuilder->execute()
#6 /var/www/nextcloud/lib/private/AppConfig.php(344): OC\DB\QueryBuilder\QueryBuilder->execute()
#7 /var/www/nextcloud/lib/private/AppConfig.php(109): OC\AppConfig->loadConfigValues()
#8 /var/www/nextcloud/lib/private/AppConfig.php(300): OC\AppConfig->getApps()
#9 /var/www/nextcloud/lib/private/legacy/OC_App.php(961): OC\AppConfig->getValues()
#10 /var/www/nextcloud/lib/private/Server.php(685): OC_App::getAppVersions()
#11 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\Server->OC\{closure}()
#12 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#13 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet()
#14 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#15 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#16 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(182): OC\AppFramework\Utility\SimpleContainer->get()
#17 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#18 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(114): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#19 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet()
#20 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#21 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#22 /var/www/nextcloud/lib/private/Server.php(1050): OC\AppFramework\Utility\SimpleContainer->get()
#23 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\Server->OC\{closure}()
#24 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#25 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet()
#26 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#27 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#28 /var/www/nextcloud/lib/private/Server.php(2010): OC\AppFramework\Utility\SimpleContainer->get()
#29 /var/www/nextcloud/lib/private/Files/View.php(118): OC\Server->getLockingProvider()
#30 /var/www/nextcloud/lib/private/Server.php(433): OC\Files\View->__construct()
#31 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(160): OC\Server->OC\{closure}()
#32 /var/www/nextcloud/3rdparty/pimple/pimple/src/Pimple/Container.php(118): OC\AppFramework\Utility\SimpleContainer->OC\AppFramework\Utility\{closure}()
#33 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(127): Pimple\Container->offsetGet()
#34 /var/www/nextcloud/lib/private/ServerContainer.php(136): OC\AppFramework\Utility\SimpleContainer->query()
#35 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(56): OC\ServerContainer->query()
#36 /var/www/nextcloud/lib/private/Server.php(1373): OC\AppFramework\Utility\SimpleContainer->get()
#37 /var/www/nextcloud/lib/base.php(594): OC\Server->boot()
#38 /var/www/nextcloud/lib/base.php(1083): OC::init()
#39 /var/www/nextcloud/console.php(48): require_once('/var/www/nextcl...')
#40 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')

Hi @Joon, have you try these lines ?

sudo -u www-data php /.../nextcloud/occ db:add-missing-indices
sudo -u www-data php /.../nextcloud/occ db:add-missing-columns

change the path of nextcloud folder by yours

Hi Mageunic,

thanks for your quick answer. I’ve tried your lines, but it didn’t change anything unfortunately. I don’t understand on which side the problem is. Is it a MariaDB / PHP or a Nextcloud problem? Some config. files seem to be lost.

The error occurred after I made a backup trail. I pulled tar.z from all Nextcloud stuff + a dump from MariaDB. After installing the backup, everything is permanently broken. I already reinstalled MariaDB + Nextcloud. It didn`t change anything, which means worst case, I have to setup the entire system new.

What’s also mysterious for me is beside that output everything seems to work perfect.

Best Jo

Hi @Joon, in your case this is a database issue or filesystem issue :

All filesystems permissions are right on nextcloud folder and subfolder?
Have you restore your backup on the same nextcloud versions as the server backup?

Hi Mageunic,

yes, all the same. I hooked up the complete system just before installing the backup stuff. I worked with the tutorial of decatec (Nextcloud-Backup) for installing the Backup. Most of his Tutorials are really great. The restoring of the backup was a trial before going on “air” and migrating all data to the server, tja…
What irritates me most, is, that it didn’t help to reinstall MariaDB + fresh nextcloud from repository: downloads.nextcloud.com.

I checked the permissions again (nextcloud + nextcloud_data), specially 3rdparty-folder itś all www-data:www-data

my cloudconfig is:

<?php
$CONFIG = array (
  'instanceid' => 'dfffgfjhklääÄ',
  'passwordsalt' => 'dtdufmuonbhxdvjfzk',
  'secret' => 'nzumhdfhpnft,jujfzpppppk,jnX',
  'trusted_domains' => 
  array (
    0 => 'XXXXXXXXXXXXXXXXXXXXXXXXXX',
    1 => 'XXXXXXXXXXXXXXXXXXXXXXXXXx',
    2 => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
    3 => 'XXXXXXXXXXXXXXXXXXXXXXXXXXX',
    4 => 'XXXXXXXXXXXXXXXXX',
    5 => 'XXXXXXXXXXXXXXXXXXXXXXXXXXg',
  ),
  'datadirectory' => 'XXXXX/XXXXXXXXXXX/nextcloud_data',
  'dbtype' => 'mysql',
  'version' => '22.0.0.11',
  'overwrite.cli.url' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextcloud_db_user',
  'dbpassword' => 'XXXXXXXXXXXXXXXXXXX',
  'installed' => true,
  'filelocking.enabled' => 'true',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'redis' => 
  array (
    'host' => '/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'default_phone_region' => 'DE',
  'overwriteprotocol' => 'https',
  'logtimezone' => 'Europe/Berlin',
  'auth.bruteforce.protection.enabled' => true,
  'maintenance' => true,
  'mail_smtpmode' => 'smtp',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'XXXXXXXXXXXXXXXXXX',
  'mail_domain' => 'XXXXXXXXXXXXXXXXXXXX',
  'mail_smtphost' => 'XXXXXXXXXXXXXXXXXXXXXXXXX',
  'mail_smtpport' => '465',
  'mail_smtpsecure' => 'ssl',
  'mail_smtpauth' => 1,
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpname' => 'XXXXXXXXXXXXXXXXXX',
  'mail_smtppassword' => 'XXXXXXXXXXXXX',
  'app_install_overwrite' => 
  array (
    0 => 'pdfdraw',
    1 => 'ocsms',
    2 => 'podcast',
    3 => 'ownpad',
    4 => 'whiteboard',
    5 => 'socialsharing_email',
    6 => 'socialsharing_diaspora',
    7 => 'socialsharing_twitter',
    8 => 'dashboardcharts',
    9 => 'activitylog',
    10 => 'files_clipboard',
  ),
  'theme' => '',
  'skeletondirectory' => '/var/www/nextcloud/nextcloud_defaultfiles',
  'share_folder' => '/Mit mir geteilt',
  "log_type" => "file",
   "logfile" => "nextcloud.log",
   "loglevel" => 2,
   "logdateformat" => "F d, Y H:i:s",
);

@Joon please remove secret information and password !!!

‘instanceid’
‘passwordsalt’
‘secret’

this is really strange …

can you check if the oc_appconfig table exists or not in your database?

Thanks for the tipp with the info!!
As you see on my mistake with the secret, I’m not a professional :/. How can I check if the config is in the database? Which command do I need when I`m in MariaDB?

Ok I used SHOW TABLES in the nextcloud db. It says: “Empty Set” how can I bring this config in?

@Joon So the database has not been restored…
have you a file like xxx.bak or xxx.sql in your backup folder ?

Thanks so much for your tip!!!
At least I only had to reinstall Nextcloud. Due to this backup thing I removed now the entire Cloud > rm -r /var/www/… then pulled the a new package again and it works finally.
Beside that I learned how to check tables of MariaDB / Mysql > mysqlshow database_name.
Problem is, I need a stable continuous backup-system, so this solution works only for this time.

It’s the second time I had problems restoring the backup following the tutorial. Do you have a tip for a good solution backing up nextcloud + its data savely + a correct dump of MariaDB would be also great.

there is no .bak in the backup and in the xxxx.sql file is
´´´´´´

in the xxxx.sql file of the backup is:

-- MariaDB dump 10.19  Distrib 10.5.11-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost    Database: nextcloud_db
-- ------------------------------------------------------
-- Server version       10.5.11-MariaDB-1:10.5.11+maria~focal

/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;

--
-- Table structure for table `oc_accounts`
--

DROP TABLE IF EXISTS `oc_accounts`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `oc_accounts` (
  `uid` varchar(64) COLLATE utf8mb4_bin NOT NULL DEFAULT '',
  `data` longtext COLLATE utf8mb4_bin NOT NULL,
  PRIMARY KEY (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPRESSED;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `oc_accounts`
--

LOCK TABLES `oc_accounts` WRITE;
/*!40000 ALTER TABLE `oc_accounts` DISABLE KEYS */;
INSERT INTO `oc_accounts` VALUES (..............................\"scope\":\"v2-federated\",\"verified\":\"1\"},\"avatar\":{\"value\":\"\",\"scope\":\"v2-federated\",\"verified\":\"0\"},\"phone\":{\"value\":\"\",\"scope\":\"v2-local\",\"verified\":\"0\"},\"twitter\":{\"value\":\"\",\"scope\":\"v2-local\",\"verified\":\"0\"}}');
/*!40000 ALTER TABLE `oc_accounts` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `oc_accounts_data`
--

DROP TABLE IF EXISTS `oc_accounts_data`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `oc_accounts_data` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `uid` varchar(64) COLLATE utf8mb4_bin NOT NULL,
  `name` varchar(64) COLLATE utf8mb4_bin NOT NULL,
  `value` varchar(255) COLLATE utf8mb4_bin DEFAULT '',
  PRIMARY KEY (`id`),
  KEY `accounts_data_uid` (`uid`),
  KEY `accounts_data_name` (`name`),
  KEY `accounts_data_value` (`value`)
) ENGINE=InnoDB AUTO_INCREMENT=265 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin ROW_FORMAT=COMPRESSED;
/*!40101 SET character_set_client = @saved_cs_client */;

--
-- Dumping data for table `oc_accounts_data`
--

LOCK TABLES `oc_accounts_data` WRITE;
/*!40000 ALTER TABLE `oc_accounts_data` DISABLE KEYS */;
INSERT INTO `oc_accounts_data` VALUES (133,_________,'');
/*!40000 ALTER TABLE `oc_accounts_data` ENABLE KEYS */;
UNLOCK TABLES;

--
-- Table structure for table `oc_activity`
--

DROP TABLE IF EXISTS `oc_activity`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `oc_activity` (
  `activity_id` bigint(20) NOT NULL AUTO_INCREMENT,
  `timestamp` int(11) NOT NULL DEFAULT 0,
  `priority` int(11) NOT NULL DEFAULT 0,
  `type` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
  `user` varchar(64) COLLATE utf8mb4_bin DEFAULT NULL,
  `affecteduser` varchar(64) COLLATE utf8mb4_bin NOT NULL,
  `app` varchar(32) COLLATE utf8mb4_bin NOT NULL,
  `subject` varchar(255) COLLATE utf8mb4_bin NOT NULL,
  `subjectparams` longtext COLLATE utf8mb4_bin NOT NULL,
  `message` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
  `messageparams` longtext COLLATE utf8mb4_bin DEFAULT NULL,
  `file` varchar(4000) COLLATE utf8mb4_bin DEFAULT NULL,
  `link` varchar(4000) COLLATE utf8mb4_bin DEFAULT NULL,
  `object_type` varchar(255) COLLATE utf8mb4_bin DEFAULT NULL,
  `object_id` bigint(20) NOT NULL DEFAULT 0,
  PRIMARY KEY (`activity_id`),
  KEY `activity_user_time` (`affecteduser`,`timestamp`),
  KEY `activity_filter_by` (`affecteduser`,`user`,`timestamp`),
:
´´´´´´

@Joon I do the backups myself so I don’t know of any good tools to recommend for this.
here is the official doc for backup nextcloud :
https://docs.nextcloud.com/server/latest/admin_manual/maintenance/backup.html

for backup :

sudo -u www-data php occ maintenance:mode --on
sudo rsync -av /…/datadirectory/ /…/backup/datadirectory/
sudo cp /…/nextcloud/config/config.php /…/backup/config.php
sudo mysqldump --single-transaction -u [user-db] -p [db_name] > /…/backup/nextcloud.bak

for restore it :

sudo rsync -av /…/backup/datadirectory/ /…/datadirectory/
sudo cp /…/backup/config.php /…/nextcloud/config/config.php
sudo mysql -u root -p
CREATE USER ‘nextclouduser’@‘localhost’ IDENTIFIED BY ‘new_password_here’;
CREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
( the bold part is only if you had enabled utf8mb4 on your nextcloud )
GRANT ALL ON nextcloud.* TO ‘nextclouduser’@‘localhost’ IDENTIFIED BY ‘user_password_here’ WITH GRANT OPTION;
FLUSH PRIVILEGES;
EXIT;
sudo mysql -u [user-db] -p [db_name] < nextcloud.bak

/!\ Replace nextcloud by your db name │ nextclouduser by your db user │ user_password_here by your user db password. if you have forgotten those informations, you can check your config.php file.

Thanks again. You brought me an easier restart after holidays :slight_smile:

1 Like