Nextcloud 500 error - redis permission issue

[/details]

Nextcloud version: 24.0.0.12
Operating system and version: Debian 11
Apache : 2.4.53
PHP version: php-fpm7.4

The issue you are facing:
I have migrated my nextcloud instance onto a new server and when trying to reach the web frontend i get a 500 error.

Looking at the nextcloud error log it’s a redis permission issue, i switched the memcache to apcu temporarily to see if everything worked ok and using this resulted in no issues, everything worked ok.

When migrating i did the following:

  • Migrated php/apache/redis/letsencrypt config filesin /etc.
  • Restored a mariadb db dump from old server to new.
  • Restored redis dump from old server to new.
  • Migrated web files in /var/www/nextcloud.

Things i have checked:

  • apache user is a member of the redis group.
  • redis is configured properly to use socket: socket perms are set to 770, socket file exists in /run/redis/ and has the correct ownership.
  • apache, redis, mariadb service is running without issues.
  • I can connect to the redis server using the redis-cli with the apache user without issue, using auth with the password in redis/nextcloud php conf file works fine too.
  • /var/log/redis has the correct ownership.

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

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

<?php
$CONFIG = array (
  'passwordsalt' => 'redacted',
  'secret' => 'redacted',
  'trusted_domains' =>
  array (
    0 => 'redacted',
  ),
  'datadirectory' => '/var/spool/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '24.0.0.12',
  'overwrite.cli.url' => 'https://localhost',
  'overwriteprotocol' => 'https',
  'dbname' => 'redacted',
  'dbhost' => 'localhost',
  'dbport' => '3306',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'oc_redacted',
  'dbpassword' => 'redacted',
  'installed' => true,
  'instanceid' => 'ocpwgxpw07ox',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'filelocking.enabled' => true,
  'redis' => [
        'host'     => '/run/redis/redis-server.sock',
        'port'     => 0,
        'password' => 'redacted',
        'dbindex' => 0,
  ],
  'log_type' => 'file',
  'logfile' => '/var/log/nextcloud/error.log',
  'loglevel' => '1',
  'logdateformat' => 'F d, Y H:i:s',
  'updater.release.channel' => 'stable',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'tls',
  'mail_sendmailmode' => 'smtp',
  'mail_from_address' => 'pox',
  'mail_domain' => 'redacted',
  'mail_smtpauthtype' => 'redacted',
  'mail_smtphost' => 'redacted',
  'mail_smtpport' => 'redacted',
  'mail_smtpauth' => 1,
  'mail_smtpname' => 'redacted',
  'mail_smtppassword' => 'redacted',
  'appcodechecker' => true,
  'simpleSignUpLink.shown' => false,
  'maintenance' => false,
  'theme' => '',
  'default_phone_region' => 'redacted',
);

Nextcloud error.log

[Tue May 24 10:17:46.865075 2022] [proxy_fcgi:error] [pid 40718] [client185.253.97.247:59348] AH01071: Got error 'PHP message:
{"reqId":"Yoyiuj6wYPhYcumfh9LyDgAAAAM","level":3,"time":"May 24, 2022 09:17:46","remoteAddr":"redacted","user":"--","app":"index",
"method":"GET","url":"/","message":"Permission denied","userAgent":"Mozilla/5.0 (X11; Linux x86_64; rv:100.0)
Gecko/20100101 Firefox/100.0","version":"24.0.0.12","exception":
{"Exception":"RedisException","Message":"Permission denied","Code":0,"Trace":
[{"file":"/var/www/nextcloud/lib/private/RedisFactory.php","line":137,"function":"pconnect","class":"Redis","type":"->"},
{"file":"/var/www/nextcloud/lib/private/RedisFactory.php","line":178,"function":"create","class":"OC\\\\RedisFactory","type":"->"},
{"file":"/var/www/nextcloud/lib/private/Memcache/Redis.php","line":43,"function":"getInstance","class":"OC\\\\RedisFactory","type":"->"},{"file":"/var/www/nextcloud/lib/private/Memcache/Factory.php","line":118,"function":
"__construct","class":"OC\\\\Memcache\\\\Redis","type":"->"},{"file":"/var/www/nextcloud/lib/private/Server.php","line":1106,
"function":"createLock...PHP message: {"reqId":"Yoyiuj6wYPhYcumfh9LyDgAAAAM","level":3,"time":"May 24, 2022 09:17:46",
"remoteAddr":"redacted","user":"--","app":"core","method":"GET","url":"/","message":"Permission denied","userAgent":
"Mozilla/5.0 (X11; Linux x86_64; rv:100.0) Gecko/20100101Firefox 100.0","version":"24.0.0.12","exception":
{"Exception":"RedisException","Message":"Permission denied","Code":0,"Trace":
[{"file":"/var/www/nextcloud/lib/private/RedisFactory.php","line":137,"function":"pconnect","class":"Redis","type":"->"},
{"file":"/var/www/nextcloud/lib/private/RedisFactory.php","line":178,"function":"create","class":"OC\\\\RedisFactory","type":"->"},
{"file":"/var/www/nextcloud/lib/private/Memcache/Redis.php","line":43,"function":"getInstance","class":"OC\\\\RedisFactory","type":"->"},{"file":"/var/www/nextcloud/lib/private/Memcache/Factory.php","line":118,
"function":"__construct","class":"OC\\\\Memcache\\\\Redis","type":"->"},
{"file":"/var/www/nextcloud/lib/private/Server.php","line":1106,"function":"createLocki...PHP message:
{"reqId":"Yoyiuj6wYPhYcumfh9LyDgAAAAM","level":3,"time":"May 24, 2022 09:17:46","remoteAddr":"185.253.97.247","user":"--","app":
"core","method":"GET","url":"/","message":"Redis server went away","userAgent":

Any advice would be greatly appreciated.

This issue is now resolved, when i went through my troubleshooting steps i only restarted apache2 & redis service. After restarting php-fpm service the dashboard now loads. I’m not entirely sure which specific change i did which resolved this.