Redis socket error

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 20.0.5): 22.1.0
Operating system and version (eg, Ubuntu 20.04): ubuntu 20.04
Apache or nginx version (eg, Apache 2.4.25): nginx 1.18.0
PHP version (eg, 7.4): php 8.0

The issue you are facing:

Is this the first time you’ve seen this error? (Y/N): y

Steps to replicate it:

  1. Upgrade from 7.4 to 8.0 PHP
  2. Install Redis-server
  3. Launch the web address : Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

I have added into redis.conf :

unixsocket /var/run/redis/redis-server.sock
unixsocketperm 770

and do :

firewall-cmd --add-port=6379/tcp --permanent

I have test lot of parameters into /var/www/nextcloud/config/config.php For Redis. I don’t know which one to use.

This don’t works :

  'filelocking.enabled' => 'true',
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
 'redis' =>  array (
    'host' => '/var/run/redis/redis-server.sock', 
    'port' => '0',
    'timeout' => '0.0',
),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',

This works on 127.0.0.1 (not www…abc…com) and after type redis-server into terminal :

   'memcache.local' => '\\OC\\Memcache\\APCu',
 'filelocking.enabled' => 'true',
 'memcache.locking' => '\\OC\\Memcache\\Redis',
 'redis' =>  array (
   'host' => 'localhost',
   'port' => 6379,
 ),
 'memcache.distributed' => '\\OC\\Memcache\\Redis',

This works on 127.0.0.1 (not www…abc…com) and after type redis-server into terminal :

  'memcache.local' => '\\OC\\Memcache\\APCu',
 'filelocking.enabled' => 'true',
 'memcache.locking' => '\\OC\\Memcache\\Redis',
 'redis' =>  array (
   'host' => 'localhost',
   'port' => 0,
 ),
 'memcache.distributed' => '\\OC\\Memcache\\Redis',

If I go to www…abc…com :

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

sudo systemctl enable redis :

Failed to enable unit: Refusing to operate on alias name or linked unit file: redis.service

WITH or WITHOUT type ‘redis-server’

systemctl status redis
● redis-server.service - Advanced key-value store
     Loaded: loaded (/lib/systemd/system/redis-server.service; enabled; vendor >
    Drop-In: /etc/systemd/system/redis-server.service.d
             └─override.conf
     Active: active (running) since Sun 2021-08-22 08:54:27 CEST; 2min 3s ago
       Docs: http://redis.io/documentation,
             man:redis-server(1)
   Main PID: 943 (redis-server)
      Tasks: 4 (limit: 9276)
     Memory: 4.3M
     CGroup: /system.slice/redis-server.service
             └─943 /usr/bin/redis-server 127.0.0.1:0

août 22 08:54:27 mgnas systemd[1]: Starting Advanced key-value store...
août 22 08:54:27 mgnas systemd[1]: Started Advanced key-value store.

The output of redis-server.log (/var/log/redis/)

936:M 22 Aug 2021 08:44:07.777 # Server initialized
936:M 22 Aug 2021 08:44:07.777 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
936:M 22 Aug 2021 08:44:07.777 * DB loaded from disk: 0.000 seconds
936:M 22 Aug 2021 08:44:07.777 * The server is now ready to accept connections at /var/run/redis/redis-server.sock
936:signal-handler (1629615239) Received SIGTERM scheduling shutdown...
936:M 22 Aug 2021 08:54:00.048 # User requested shutdown...
936:M 22 Aug 2021 08:54:00.048 * Saving the final RDB snapshot before exiting.
936:M 22 Aug 2021 08:54:00.051 * DB saved on disk
936:M 22 Aug 2021 08:54:00.051 * Removing the pid file.
936:M 22 Aug 2021 08:54:00.051 * Removing the unix socket file.
936:M 22 Aug 2021 08:54:00.052 # Redis is now ready to exit, bye bye...
943:C 22 Aug 2021 08:54:27.964 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
943:C 22 Aug 2021 08:54:27.965 # Redis version=5.0.7, bits=64, commit=00000000, modified=0, pid=943, just started
943:C 22 Aug 2021 08:54:27.965 # Configuration loaded
943:C 22 Aug 2021 08:54:27.965 * supervised by systemd, will signal readiness
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.7 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 0
 |    `-._   `._    /     _.-'    |     PID: 943
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

943:M 22 Aug 2021 08:54:27.980 # Server initialized
943:M 22 Aug 2021 08:54:27.980 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
943:M 22 Aug 2021 08:54:27.981 * DB loaded from disk: 0.001 seconds
943:M 22 Aug 2021 08:54:27.981 * The server is now ready to accept connections at /var/run/redis/redis-server.sock

The output of your Nextcloud log in Admin > Logging:

Not available

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'IDDDDD',
  'passwordsalt' => 'PASSSSSS',
  'secret' => 'SECRETTTT',
  'default_phone_region' => 'FR',
  'trusted_domains' => 
  array (
    0 => 'www..abc..com',
    1 => 'abc.local',
  ),
  'datadirectory' => '/media/XXX/disque_wd/data',
  'dbtype' => 'mysql',
  'version' => '22.1.0.1',
  'preview_max_x' => '2048',
  'preview_max_y' => '2048',
  'jpeg_quality' => '60',


  'overwrite.cli.url' => 'https://www..abc..com',
  'dbname' => 'DBNAMEEE',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'DBUSERRR',
  'dbpassword' => 'DBPASSSSS',
  'installed' => true,
  'filesystem_check_changes' => 1,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'filelocking.enabled' => 'true',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => array (
    'host' => 'localhost',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'memcache.distributed' => '\\OC\\Memcache\\Redis',
  'maintenance' => false,
  'updater.release.channel' => 'stable',
  'theme' => '',
  'loglevel' => 2,
  'app_install_overwrite' => array (
    0 => 'previewgenerator',
  ),
);

The output of your Apache/nginx/system log in /var/log/____:

2021/08/22 08:54:27 [warn] 970#970: "ssl_stapling" ignored, host not found in OCSP responder "r3.o.lencr.org" in the certificate "/etc/letsencrypt/live/www..abc..com/fullchain.pem"

I just want my server running into redis socket. With APCu it works good but i want Redis.

Looks fine however Port 6379 does not have to be open if you want use a websocket connection and/or Redis is running on the same machine. But you have to add the user of the web server (www-data) to the redis group in order to allow Nextcloud to access the web socket…

usermod -aG redis www-data

…then you should be able to use the first config you posted.

after usermod no changes
https://127.0.0.1/ → internal error

www…abc…com → wait, wait, wait and don’t find the address

Which one of your three config.php examples is in use? Does this still happen with all three of them?

‘memcache.local’ => ‘\OC\Memcache\APCu’,
‘filelocking.enabled’ => ‘true’,
‘memcache.locking’ => ‘\OC\Memcache\Redis’,
‘redis’ => array (
‘host’ => ‘/var/run/redis/redis-server.sock’,
‘port’ => 0,
‘timeout’ => 0.0,
),
‘memcache.distributed’ => ‘\OC\Memcache\Redis’,

Did you also switch port 6379 to port 0 in /etc/redis/redis.conf?

And don’t forgert to restart all relevant services or better reboot your machine after you made changes to the redis.conf.

# Accept connections on the specified port, default is 6379 (IANA #815344).
# If port 0 is specified Redis will not listen on a TCP socket.
port 0

Hmm I wouldn’t call myself an expert when it comes to redis… But it works for me.

I can post the steps from my personal docs… if you do an apt purge redis-server and reinstall redis-server before you try the following steps, you can start with a fresh default config.

Backup the Redis configuration file:

cp /etc/redis/redis.conf /etc/redis/redis.conf.bak

Adjust the configuration:

sed -i "s/port 6379/port 0/" /etc/redis/redis.conf
sed -i s/\#\ unixsocket/\unixsocket/g /etc/redis/redis.conf
sed -i "s/unixsocketperm 700/unixsocketperm 770/" /etc/redis/redis.conf
sed -i "s/# maxclients 10000/maxclients 512/" /etc/redis/redis.conf
usermod -aG redis www-data

Backup the file sysctl.conf:

cp /etc/sysctl.conf /etc/sysctl.conf.bak

Set avm.overcommit_memory to a value of 1:

sed -i '$avm.overcommit_memory = 1' /etc/sysctl.conf

Reboot the server!

This steps are taken from this tutorial. (It’s in German)

The relevant lines in my config.php:

'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),

I have done all you write:

127.0.0.1 → Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

www…abc…com → wait, wait, wait… don’t find

with or without ‘redis-server’ in terminal

Sorry then I unfortunately do not know what the problem is. Maybe not all required PHP modules installed and active? Something in the NGINX or PHP configuration?

When it comes to NGINX I have no experience because I use Apache…But you can maybe use the guide I linked as a reference…

ok thank you for respond to me and try to fix it.
I hope some other people help me to fix it.