Can't access nextcloud after setting up redis

Support intro

posted this on “installation” section, didn’t notice a support section until now
i’m new to nextcloud. Almost done setting up a fresh nextcloud 21 until i reached redis.

I followed this guide for my nextcloud installation

for the redis setup, i initially followed this guide, but realized my nextcloud installation guide also have a redis section, so I undo everything i did (except the permission), and went back to the redis section in my first nextcloud installation guide.

thank you for the help. I’m extremely puzzled…

Nextcloud version (eg, 20.0.5): 21.0.2
Operating system and version (eg, Ubuntu 20.04): ubuntu 21.04
Apache or nginx version (eg, Apache 2.4.25): nginx 1.18
PHP version (eg, 7.4): 7.4 (I do have other versions installed)

The issue you are facing:
after setting up redis, my nextcloud server suddenly has a error message:

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.

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

Steps to replicate it:

  1. setup nextcloud normally using this guide until you reaches Redis setup.

  2. open the Redis configuration file at /etc/redis/redis.conf use command sudo nano /etc/redis/redis.conf

  3. change port 6379 to port 0, uncommentunixsocket /var/run/redis/redis.sock and unixsocketperm 700 then change unixsocketperm 700to unixsocketperm 770

  4. save and quit, then add the user www-data to the redis group by using the command: ’ sudo usermod -a -G redis www-data

  5. After this i realized i’m using nginx instead of Apache, so i went back to my original guide for redis setup. and undo everything i did except the permission.

  6. Comment unixsocket /var/run/redis/redis.sock and unixsocketperm 770

  7. change port 0 to port 6379

  8. using the original guide i used NC installation. edit nextCloud configuration file by using command “sudo nano /usr/share/nginx/nextcloud/config/config.php”

  9. add the following code to the ending ); line.

'memcache.distributed' => '\OC\Memcache\Redis',
'memcache.local' => '\OC\Memcache\Redis',
'memcache.locking' => '\OC\Memcache\Redis',
'redis' => array(
     'host' => 'localhost',
     'port' => 6379,
     ),
  1. Save and close the file. Then restart Nginx and PHP-FPM using command “sudo systemctl restart nginx php7.4-fpm”

  2. now go back to the NC webpage, a the internal error is there.

The output of your Nextcloud error.log

2021/06/10 18:33:30 [crit] 192871#192871: *3372 SSL_do_handshake() failed (SSL: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share) while SSL handshaking, client: 35.203.252.150, server: 0.0.0.0:443

2021/06/10 18:38:02 [crit] 192871#192871: *3460 SSL_do_handshake() failed (SSL: error:141CF06C:SSL routines:tls_parse_ctos_key_share:bad key share) while SSL handshaking, client: 35.203.252.118, server: 0.0.0.0:443

2021/06/10 20:03:43 [error] 193335#193335: *5006 access forbidden by rule, client: 45.146.165.123, server: raid1.duckdns.org, request: "GET /console/ HTTP/1.1", host: "207.38.189.168:443"

2021/06/10 20:12:35 [error] 203863#203863: *5136 access forbidden by rule, client: 192.168.1.1, server: raid1.duckdns.org, request: "GET /.well-known/webfinger HTTP/2.0", host: "raid1.duckdns.org"

2021/06/10 20:12:35 [error] 203863#203863: *5136 access forbidden by rule, client: 192.168.1.1, server: raid1.duckdns.org, request: "GET /.well-known/nodeinfo HTTP/2.0", host: "raid1.duckdns.org"

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

<?php
$CONFIG = array (
  'instanceid' => 'redacted',
  'passwordsalt' => 'redacted',
  'secret' => 'redacted',
  'trusted_domains' =>
  array (
    0 => 'redacted',
  ),
  'datadirectory' => '/mnt/raid1/nextcloud-data/',
  'dbtype' => 'mysql',
  'version' => '21.0.2.1',
  'overwrite.cli.url' => 'redacted',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'redacted',
  'dbpassword' => 'redacted',
  'installed' => true,

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

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

nothing in there. is there a way to check error history? or is everything just in one log

What i’v tried

  • add an extra \ to the redis config
  • double check on my ufw firewall setting regarding port 6379
  • double check on my portfowarding on router regarding port 6379
  • uninstall and reinstall of redis-server
1 Like

Point 3 might be your problem. You’re not running redis on port 6379 but as socket. So your config file should be the following.

‘redis’ =>
array (
‘host’ => ‘/var/run/redis/redis.sock’,
‘port’ => 0,
),’

I undo everything i did, see point 5,6,7

Try the following.

Check through CLI whether the Redis server is up and is accepting connections to its socket on port 6379 (assuming for all the below that you have no password set):

sudo redis-cli -h 127.0.0.1 -p 6379
shows:
redis 127.0.0.1:6379>

Type: ping
The answer should be: PONG

Leave Redis-console by typing: quit

If Redis doesn’t give you the “Pong” something is wrong with your redis-configuration.

If you get back that “PONG” make sure you have in NC’s config:

--------------- 8< ---------------

  'redis' => 
  array (
    'host' => 'localhost',
    'port' => 6379,
    'timeout' => 0,
    'dbindex' => 0,
  ),

--------------- >8 ---------------

Now:
sudo chown -R redis.www-data /var/run/redis

And finally:
Restart the Redis server.

Does it work now?

Hi @notmike

If you run redis on the same server as your nextcloud there is really no need to run it on a dedicated port and open that port to the whole world.

Remove redis including the config files

apt purge redis-server

Install packages again

apt install redis-server php7.4-redis

Configure Redis

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

Configure it in the config.php

'redis' => 
array (
'host' => '/var/run/redis/redis-server.sock',
'port' => 0,
'timeout' => 0.0,
),

It is working like this on my instance like a charm for years. Alltough I have to say that I use apcu for local memchache. My config in the config.php looks like this…

'memcache.local' => '\OC\Memcache\APCu',
'memcache.locking' => '\OC\Memcache\Redis',

…but I see no reason why it should not work with

'memcache.local' => '\OC\Memcache\Redis',

@Tamsy
It does not work

I followed what you instructed:
it answered: PONG

changed my redi config in nginx:

‘memcache.distributed’ => ‘\OC\Memcache\Redis’,
‘memcache.local’ => ‘\OC\Memcache\Redis’,
‘memcache.locking’ => ‘\OC\Memcache\Redis’,
‘redis’ => array(
‘host’ => ‘localhost’,
‘port’ => 6379,
‘timeout’ => 0,
‘dbindex’ => 0,
),

executed sudo chown -R redis.www-data /var/run/redis
restarted redis server via command 'sudo systemctl restart redis-server

the error persists.

Thank you @bb77 this fixed it!

1 Like

This has been solved, I appreciate everyone’s help!