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.
Typical scenario
After an operating system upgrade the package replaces redis.conf, the unixsocket line is commented out again and the socket file is gone. nextcloud.log shows RedisException: Redis went away, uploads hang and some pages return 500. config.php still points to /run/redis/redis-server.sock. First check: does the socket file exist, and is the web server user a member of the redis group?
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.
What does Nextcloud use Redis for exactly?
As a distributed cache and for transactional file locking (memcache.locking). Without Redis, Nextcloud locks files through the database, which is slower under many concurrent accesses. The service is optional, but a configuration you set has to work.
Unix socket or TCP, which is better?
If Redis runs on the same host, the socket is faster and opens no network port. With TCP, bind 127.0.0.1 and a password belong in the configuration, otherwise the service can be attacked from outside. The socket needs correct group permissions for the web server user.
How do I notice Redis outages sooner?
Depending on the unit file, systemd restarts Redis after a crash automatically, and the outage goes unnoticed. Count restarts in journalctl -u redis-server and let monitoring run redis-cli ping regularly, ideally with the socket path from config.php.