# Configure Redis UNIX socket

1. <span class="flex size-7 shrink-0 items-center justify-center rounded-full bg-neutral text-body font-medium text-secondary">1</span><div class="flex min-w-0 flex-1 flex-col gap-xs"><span class="flex min-h-7 items-center text-[16px] leading-[20px] font-medium text-primary">Set Redis to listen on a Unix socket</span><span class="text-body text-secondary">Edit **/etc/redis/redis.conf** and add or uncomment: unixsocket /var/run/redis/redis-server.sock unixsocketperm 770 You can leave the TCP &#96;port 6379&#96; line as-is or set &#96;port 0&#96; to disable TCP entirely once you confirm the socket works.</span></div>
2. <span class="flex size-7 shrink-0 items-center justify-center rounded-full bg-neutral text-body font-medium text-secondary">2</span><div class="flex min-w-0 flex-1 flex-col gap-xs"><span class="flex min-h-7 items-center text-[16px] leading-[20px] font-medium text-primary">Fix the socket directory and ownership</span><span class="text-body text-secondary">The socket file is created by the redis user (usually &#96;redis&#96;). Your web server user (usually &#96;www-data&#96; 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 &#96;redis:redis&#96; means www-data (now in the redis group) can connect.</span></div>
3. <span class="flex size-7 shrink-0 items-center justify-center rounded-full bg-neutral text-body font-medium text-secondary">3</span><div class="flex min-w-0 flex-1 flex-col gap-xs"><span class="flex min-h-7 items-center text-[16px] leading-[20px] font-medium text-primary">Restart Redis and verify the socket exists</span><span class="text-body text-secondary">sudo 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 &#96;sudo systemctl status redis-server&#96; and &#96;journalctl -u redis-server&#96; for errors — often it's a directory permissions or AppArmor issue.</span></div>
4. <span class="flex size-7 shrink-0 items-center justify-center rounded-full bg-neutral text-body font-medium text-secondary">4</span><div class="flex min-w-0 flex-1 flex-col gap-xs"><span class="flex min-h-7 items-center text-[16px] leading-[20px] font-medium text-primary">Test the socket connection</span><span class="text-body text-secondary">redis-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.</span></div>
5. <span class="flex size-7 shrink-0 items-center justify-center rounded-full bg-neutral text-body font-medium text-secondary">5</span><div class="flex min-w-0 flex-1 flex-col gap-xs"><span class="flex min-h-7 items-center text-[16px] leading-[20px] font-medium text-primary">Update config.php to use only the socket block</span><span class="text-body text-secondary">Remove or comment out the TCP &#96;'redis' =&gt; array('host' =&gt; 'localhost', 'port' =&gt; 6379, ...)&#96; block, keeping only: 'redis' =&gt; array ( 'host' =&gt; '/var/run/redis/redis-server.sock', 'port' =&gt; 0, 'timeout' =&gt; 1.5, 'dbindex' =&gt; 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.</span></div>
6. <span class="flex size-7 shrink-0 items-center justify-center rounded-full bg-neutral text-body font-medium text-secondary">6</span><div class="flex min-w-0 flex-1 flex-col gap-xs"><span class="flex min-h-7 items-center text-[16px] leading-[20px] font-medium text-primary">Clear cache and restart PHP-FPM</span><span class="text-body text-secondary">sudo 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.</span></div>
7. <span class="flex size-7 shrink-0 items-center justify-center rounded-full bg-neutral text-body font-medium text-secondary">7</span><div class="flex min-w-0 flex-1 flex-col gap-xs"><span class="flex min-h-7 items-center text-[16px] leading-[20px] font-medium text-primary">Confirm Nextcloud is actually using it</span><span class="text-body text-secondary">Check Settings &gt; Administration &gt; 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.</span></div>