What is causing RedisException: Connection lost when Starting code integrity check begins?

When I try to upgrade my nextcloud to latest version I am getting this error:

Starting code integrity check...

RedisException: Connection lost

Nextcloud version (eg, 20.0.5): 21.0.3
Operating system and version (eg, Ubuntu 20.04): 20.04
Apache or nginx version (eg, Apache 2.4.25): Apache2.4
PHP version (eg, 7.4): 7.4

The issue you are facing:

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

Steps to replicate it:

  1. sudo -u www-data ./occ upgrade

The output of your Nextcloud log in Admin > Logging:

 {"reqId":"xcKKnzipv9pnXARnJxQi","level":3,"time":"2021-08-16T06:07:14+00:00","remoteAddr":"","user":"--","app":"core","method":"","ur     l":"--","message":{"Exception":"RedisException","Message":"Connection lost","Code":0,"Trace":[{"file":"/var/www/html/nextcloud/lib/pr     ivate/Memcache/Redis.php","line":55,"function":"get","class":"Redis","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Integr     ityCheck/Checker.php","line":441,"function":"get","class":"OC\\Memcache\\Redis","type":"->"},{"file":"/var/www/html/nextcloud/lib/pri     vate/IntegrityCheck/Checker.php","line":459,"function":"getResults","class":"OC\\IntegrityCheck\\Checker","type":"->"},{"file":"/var/     www/html/nextcloud/lib/private/IntegrityCheck/Checker.php","line":531,"function":"storeResults","class":"OC\\IntegrityCheck\\Checker"     ,"type":"->"},{"file":"/var/www/html/nextcloud/lib/private/IntegrityCheck/Checker.php","line":606,"function":"verifyAppSignature","cl     ass":"OC\\IntegrityCheck\\Checker","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Updater.php","line":288,"function":"runI     nstanceVerification","class":"OC\\IntegrityCheck\\Checker","type":"->"},{"file":"/var/www/html/nextcloud/lib/private/Updater.php","li     ne":132,"function":"doUpgrade","class":"OC\\Updater","type":"->"},{"file":"/var/www/html/nextcloud/core/Command/Upgrade.php","line":2     55,"function":"upgrade","class":"OC\\Updater","type":"->"},{"file":"/var/www/html/nextcloud/apps/bookmarks/vendor/symfony/console/Com     mand/Command.php","line":255,"function":"execute","class":"OC\\Core\\Command\\Upgrade","type":"->"},{"file":"/var/www/html/nextcloud/     apps/bookmarks/vendor/symfony/console/Application.php","line":1009,"function":"run","class":"Symfony\\Component\\Console\\Command\\Co     mmand","type":"->"},{"file":"/var/www/html/nextcloud/apps/bookmarks/vendor/symfony/console/Application.php","line":273,"function":"do     RunCommand","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":"/var/www/html/nextcloud/apps/bookmarks/vendor/sy     mfony/console/Application.php","line":149,"function":"doRun","class":"Symfony\\Component\\Console\\Application","type":"->"},{"file":     "/var/www/html/nextcloud/lib/private/Console/Application.php","line":215,"function":"run","class":"Symfony\\Component\\Console\\Appli     cation","type":"->"},{"file":"/var/www/html/nextcloud/console.php","line":100,"function":"run","class":"OC\\Console\\Application","ty     pe":"->"},{"file":"/var/www/html/nextcloud/occ","line":11,"args":["/var/www/html/nextcloud/console.php"],"function":"require_once"}],     "File":"/var/www/html/nextcloud/lib/private/Memcache/Redis.php","Line":55,"CustomMessage":"--"},"userAgent":"--","version":"21.0.3.1"     }

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

<?php
$CONFIG = array (
  'instanceid' => 'ocr2fw9pzn5a',
  'passwordsalt' => '24QdCbKXo/MTqBnT2WZwK/G620EIM/',
  'secret' => 'HnyaVGitcBtN9i8dBneWxRaXTZo//Wjw3CNSLLG0dU8iRIqG',
  'filelocking.enabled' => 'true',
  'memcache.disributed' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '192.168.1.10',
    'port' => 6379,
    'timeout' => 0.0,
    'password' => 'secret',
    'dbindex' => 0,
  ),
  'trusted_domains' => 
  array (
    0 => '192.168.1.10',
    1 => 'example.com'
  ),
  'datadirectory' => '/media/storage/data',
  'dbtype' => 'mysql',
  'version' => '21.0.3.1',
  'overwriteprotocol' => 'https',
  'overwritehost' => 'example.com',
  'overwrite.cli.url' => 'https://example.com/nextcloud',
  'dbname' => 'nextcloud',
  'dbhost' => '192.168.1.10',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nextcloud',
  'dbpassword' => 'secret',
  'installed' => true,
  'htaccess.RewriteBase' => '/nextcloud',
  'session_lifetime' => 86400,
  'session_keepalive' => true,
  'has_rebuilt_cache' => true,
  'maintenance' => true,
  'theme' => '',
  'logfile' => '/var/log/nextcloud/nextcloud.log',
  'loglevel' => 1,
  'updater.release.channel' => 'stable',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'kontact',
  'mail_domain' => 'example.com',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'smtp.example.com',
  'mail_smtpport' => '25',
  'mail_smtpname' => 'kontact@example.com',
  'mail_smtppassword' => 'secret',
);

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

[Sun Aug 15 22:41:04.014223 2021] [php7:warn] [pid 11135] [client 192.168.1.19:56175] PHP Warning:  require_once(/var/www/html/nextcloud/config/config.php): failed to open stream: Permission denied in /var/www/html/nextcloud/updater/index.php on line 177
[Sun Aug 15 22:41:04.014393 2021] [php7:error] [pid 11135] [client 192.168.1.19:56175] PHP Fatal error:  require_once(): Failed opening required '/var/www/html/nextcloud/updater/../config/config.php' (include_path='.:/usr/share/php') in /var/www/html/nextcloud/updater/index.php on line 177```