What the message looks like
{"reqId":"Yk3x...","level":3,"message":"RedisException: Redis went away in /var/www/nextcloud/lib/private/RedisFactory.php"}Common causes
- Redis is not running: it crashed, was stopped by an update, or was killed by the out-of-memory killer.
- The
redisblock inconfig.phppoints to the wrong host, port or socket path. - Redis listens on a Unix socket, but the web server user is not in the
redisgroup orunixsocketpermis too strict. - Redis closes idle or overloaded connections, for example because of a low
timeout,maxclientsor a memory limit.
Check
- Is Redis running?
systemctl status redis-server --no-pager - Does Redis answer on the socket?
redis-cli -s /run/redis/redis-server.sock ping - What does Nextcloud have configured?
- Why did Redis stop?
Fix
- Start it and keep it enabled:
systemctl enable --now redis-server. - Make Nextcloud use the same endpoint Redis listens on, for example
occ config:system:set redis host --value=/run/redis/redis-server.sockandocc config:system:set redis port --value=0 --type=integer. - For a socket, add the web server user to the group:
usermod -aG redis www-data, setunixsocketperm 770inredis.conf, then restart Redis and PHP-FPM. - If the kernel log shows Redis killed for memory, give the host more RAM or lower the other services. Set a
maxmemorythat fits. - Check
nextcloud.logagain after a few minutes to confirm the error is gone.
FAQ
Can I just remove Redis from config.php?
Yes, as a test or a stopgap. Nextcloud then falls back to the database for file locking, which is slower and can cause more lock conflicts. Fix Redis rather than leaving it out.
Is the data lost when Redis goes away?
No. Redis holds locks and cache, not your files. After a restart the locks are rebuilt. Stuck locks from a crash can be cleaned with the file-locked entry in this lexicon.