Redis Unix Socket

I have a Nextcloud running on an Ubuntu Server 20.04. Before the Redis installation it was working perfectly, but since i configured the unix socket redis is using, the nextcloud crashes on every visit.

In the error log of the apache Server i found this →

[Mon Dec 13 06:48:14.900434 2021] [php:error] [pid 43062] [client 143.224.1.1:56115] PHP Fatal error: Uncaught OCP\HintException: [0]: Memcache \OC\Memcache\Redis not available for local cache (Is the matching PHP module installed and enabled?)\n\n thrown in /var/www/nextcloud/lib/private/Memcache/Factory.php on line 89

Pls help

Hi @scarw03

…is it? :wink: Make sure that the PHP redis module is actualy installed…

sudo apt install php-redis

…also make sure that the following is set in /etc/redis/redis.conf

port 0
unixsocketperm 770 

…and add the redis user to the www-data group

sudo usermod -aG redis www-data

Don’t forget to restart all services or reboot after you made any chancges.

Hope that helps…

The php module was installed before, i made the changes again, because they were already configured, rebooted the VM but nothing changes… The Nextcloud web interface says internal error, and the error.log the same like written in the topic…

I dont know what it else could be…

What are your Redis settings in config.php?

image

Here we are… I changed the passwords everywhere, so dont wonder about it.
The most common mistake to have redis-server.sock in the config i changed before weeks.

I have:

  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'memcache.local' => '\\OC\\Memcache\\Redis',
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis.sock',
    'port' => 0,
    'dbindex' => 0,
    'timeout' => 1.5,
  ),

Does redis.sock exist?
ls -l /var/run/redis/redis.sock
And are the permissions okay for:
/var/run/redis/

Edit: Do you know there is a typo in Trusted domains? An R is missing.

The permissions of the socket are followings:
image

image

Yeah there is a R missing, i deleted some letters, thats not the original, but thx.

I added the ‘memcache.distributed and the dbindex’ but nothing changed
It still doesnt work.

In redis.conf I’ve also set;

unixsocket /var/run/redis/redis.sock
supervised systemd
pidfile /var/run/redis/redis-server.pid

If you:

sudo redis-cli ping

on commandline, does redis respond with a pong?

Nextcloud web server is running as wwwrun or www-data etc. Therefore you have to make sure that the relevant user is allowed to access the socket. This can be done, e.g. by adding the user to the redis group.
Please use the search function of this forum to find more details. This question has already been asked and answered multiple times in the past.

1 Like

I already had this lines you wrote in my conf, but the cli ping was refused…

“Could not connect to Redis at 127.0.0.1:6379: Connection refused”

…but did you also add the www-data user to the redis group…?

sudo usermod -aG redis www-data

@j-ed: The webserver on Ubuntu is running on www-data:www-data as bb77 already wrote:

sudo usermod -aG redis www-data

Because the redis.sock file is there and owned by redis, this looks indeed like a permission problem.

1 Like

@scarw03

You can check the group members of the redis group with…

grep redis /etc/group

or you can check if www-data is in the redis group with…

groups www-data

Or just execute the usermod command I posted. It does no harm and has (most likely) to be done anyways :wink:

Could you try:

sudo redis-cli -s /var/run/redis/redis.sock ping

To make sure it isn´t a permission problem?

The command line write “PONG”

The www-data is in the right group

sudo -u www-data redis-cli -s /var/run/redis/redis.sock ping
?

Again PONG

Then we have to look at Nextcloud or php. Php-redis is installed?

sudo apt install php-redis

Yeah its installed.

In Nextcloud docs I see:

'memcache.local' => '\OC\Memcache\Redis',
'memcache.distributed' => '\OC\Memcache\Redis',
'redis' => [
     'host'     => '/var/run/redis/redis.sock',
     'port'     => 0,
     'dbindex'  => 0,
     'timeout'  => 1.5,
],

The differences are: [ ] instead of array () and single backslashes \
Maybe something changes the way this is working?