- 1
Set Redis to listen on a Unix socketEdit /etc/redis/redis.conf and add or uncomment: unixsocket /var/run/redis/redis-server.sock unixsocketperm 770 You can leave the TCP `port 6379` line as-is or set `port 0` to disable TCP entirely once you confirm the socket works.
- 2
Fix the socket directory and ownershipThe socket file is created by the redis user (usually `redis`). Your web server user (usually `www-data` for PHP-FPM/nginx or apache) needs read/write access to it. Add www-data to the redis group: sudo usermod -aG redis www-data Then make sure the socket's group matches: unixsocketperm 770 combined with group ownership `redis:redis` means www-data (now in the redis group) can connect.
- 3
Restart Redis and verify the socket existssudo systemctl restart redis-server ls -l /var/run/redis/redis-server.sock You should see something like srwxrwx--- 1 redis redis ... redis-server.sock. If the file's missing, check `sudo systemctl status redis-server` and `journalctl -u redis-server` for errors — often it's a directory permissions or AppArmor issue.
- 4
Test the socket connectionredis-cli -s /var/run/redis/redis-server.sock ping This should return PONG. If it hangs or errors, the socket permissions or path are wrong — recheck step 2.
- 5
Update config.php to use only the socket blockRemove or comment out the TCP `'redis' => array('host' => 'localhost', 'port' => 6379, ...)` block, keeping only: 'redis' => array ( 'host' => '/var/run/redis/redis-server.sock', 'port' => 0, 'timeout' => 1.5, 'dbindex' => 0, ), Use dbindex 0 unless you're intentionally isolating Nextcloud from other apps sharing this Redis instance — keep it consistent, don't leave a stray db index from testing.
- 6
Clear cache and restart PHP-FPMsudo systemctl restart php8.x-fpm (match your actual PHP version) Then as your Nextcloud admin user, run: sudo -u www-data php occ status sudo -u www-data php occ maintenance:repair This confirms Nextcloud can reach Redis and forces it to re-read config.php.
- 7
Confirm Nextcloud is actually using itCheck Settings > Administration > Overview for warnings, or run: sudo -u www-data php occ check You can also watch live traffic on the socket with: redis-cli -s /var/run/redis/redis-server.sock monitor while clicking around in Nextcloud — you should see GET/SET/lock commands streaming in.