Login on nextcloud GUI fails

Nextcloud version (eg, 18.0.2): 19.0.4.2
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04.1
Apache or nginx version (eg, Apache 2.4.25): 2.4.41
PHP version (eg, 7.1): 7.4.3

The issue you are facing:

We’ve got a nextcloud home/sme server (Ubuntu 20.04.1) running in the office which should replace our old data storage.

I’ve had it running before, but today I wanted to start importing files and was greeted by an error message after login.
I guess that the login works, but every action thereafter breaks.
When I call the base url I am redirected to /apps/files and see 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.

In the server log unter /var/log/nextcloud/nextcloud.log I see the following message:

[...] "app":"core","method":"GET","url":"/apps/files/","message":{"Exception":"RuntimeException","Message":"File entry could not be inserted but could also not be selected with getId() in order to perform an update. Please try again.","Code":0,"Trace":[{"file":"/var/www/nextcloud/lib/private/Files/Cache/Scanner.php","line":294,"function":"insert","class":"OC\\Files\\Cache\\Cache","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Scanner.php","line":224,"function":"addToCache","class":"OC\\Files\\Cache\\Scanner","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Scanner.php","line":338,"function":"scanFile","class":"OC\\Files\\Cache\\Scanner","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1339,"function":"scan","class":"OC\\Files\\Cache\\Scanner","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1383,"function":"getCacheEntry","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Node/Root.php","line":201,"function":"getFileInfo","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Node/Folder.php","line":138,"function":"get","class":"OC\\Files\\Node\\Root","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Node/Folder.php","line":147,"function":"get","class":"OC\\Files\\Node\\Folder","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/SimpleFS/SimpleFolder.php","line":72,"function":"nodeExists","class":"OC\\Files\\Node\\Folder","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/JSCombiner.php","line":117,"function":"fileExists","class":"OC\\Files\\SimpleFS\\SimpleFolder","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/JSCombiner.php","line":103,"function":"isCached","class":"OC\\Template\\JSCombiner","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/JSResourceLocator.php","line":116,"function":"process","class":"OC\\Template\\JSCombiner","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/JSResourceLocator.php","line":72,"function":"cacheAndAppendCombineJsonIfExist","class":"OC\\Template\\JSResourceLocator","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/ResourceLocator.php","line":79,"function":"doFind","class":"OC\\Template\\JSResourceLocator","type":"->"},{"file":"/var/www/nextcloud/lib/private/TemplateLayout.php","line":346,"function":"find","class":"OC\\Template\\ResourceLocator","type":"->"},{"file":"/var/www/nextcloud/lib/private/TemplateLayout.php","line":173,"function":"findJavascriptFiles","class":"OC\\TemplateLayout","type":"::"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":185,"function":"__construct","class":"OC\\TemplateLayout","type":"->"},{"file":"/var/www/nextcloud/lib/private/Template/Base.php","line":132,"function":"fetchPage","class":"OC_Template","type":"->"},{"file":"/var/www/nextcloud/lib/private/legacy/OC_Template.php","line":334,"function":"printPage","class":"OC\\Template\\Base","type":"->"},{"file":"/var/www/nextcloud/index.php","line":63,"function":"printExceptionErrorPage","class":"OC_Template","type":"::"}],"File":"/var/www/nextcloud/lib/private/Files/Cache/Cache.php","Line":324,"CustomMessage":"--"},"userAgent":"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:82.0) Gecko/20100101 Firefox/82.0","version":"19.0.4.2"}

Nextcloud config:

$CONFIG = array (
  'passwordsalt' => '[redacted]',
  'secret' => '[redacted]',
  'trusted_domains' => 
  array (
    0 => 'localhost',
    1 => '[redacted]',
    2 => '[redacted]',
    3 => '[redacted]',
  ),
  'datadirectory' => '/mnt/ncdata',
  'dbtype' => 'pgsql',
  'version' => '19.0.4.2',
  'overwrite.cli.url' => '[redacted]',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'ncadmin',
  'dbpassword' => '[redacted]',
  'installed' => true,
  'instanceid' => '[redacted]',
  'upgrade.disable-web' => 'true',
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'loglevel' => '2',
  'log.condition' => 
  array (
    'apps' => 
    array (
      0 => 'admin_audit',
    ),
  ),
  'mail_smtpmode' => 'smtp',
  'remember_login_cookie_lifetime' => '1800',
  'log_rotate_size' => '10485760',
  'trashbin_retention_obligation' => 'auto, 180',
  'versions_retention_obligation' => 'auto, 365',
  'simpleSignUpLink.shown' => 'false',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => true,
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.5,
    'dbindex' => 0,
    'password' => '[redacted]',
  ),
  'logtimezone' => 'Europe/Zurich',
  'htaccess.RewriteBase' => '/',
  'maintenance' => false,
  'mail_from_address' => 'noreply',
  'mail_sendmailmode' => 'smtp',
  'mail_domain' => '[redacted]',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpsecure' => '[redacted]',
  'mail_smtphost' => '[redacted]',
  'mail_smtpport' => '[redacted]',
  'mail_smtpauth' => 1,
  'mail_smtpname' => '[redacted]',
  'mail_smtppassword' => '[redacted]',
  'data-fingerprint' => '[redacted]',
);

The only information about this error was a post writing about a missing auto increment on the column fileid in the table oc_filecache, which is from May’19.

I have updated from Version 19.0.2 to 19.0.4, but to no avail.

Any ideas on how to get to the bottom of this?

Can you check the webserver’s error logfile if there is more information. To make sure everything in the update has been run completely, you can retrigger the run on the terminal: sudo -u www-data php occ upgrade (it will just execute all missing steps from the last/current upgrade and doesn’t download the next upgrade).

There is only the message which is in the original question.

I have now solved the problem by completely reinstalling the instance and now it works. Sadly I have no idea what caused the issue.