Can't access nextcloud after setting up 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!

Battling to get Redis working on Centos 7 with Nginx. I’ll keep going! This post is two years old but gives some kind of indication about what one needs to do.

I re-open this thread because i’ve tried your solution but it still not work. Internal server error when loading the NC page.

Here is my config.php :

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

When i comment that part in the config file then i can access again to my interface.

i’m on debian 11 with NC 27.

thanks in advance for your help

Not sure why it doesn’t work for you, but here’s a few things you could check…

  • Check if the Redis server installed and the Redis service is running:

    systemctl status redis.service
    
  • Check if the appropriate PHP module is installed and enabled?

    apt list php*-redis
    
    php --ri redis
    
  • Check the config file /etc/redis/redis.conf, especially the following lines:

    bind 127.0.0.1 ::1
    port 0
    unixsocketperm 770
    unixsocket /var/run/redis/redis-server.sock
    

    If unsure post your config here, you can use the follwing command to print only the uncommented lines:

    cat /etc/redis/redis.conf | grep -v '^$\|^#'
    
  • Check if the www-data user is in the redis group

    groups www-data
    

it’s active, running and enabled.


the one with [installed] at the end of the line is this one :

  • php8.1-redis/bullseye,now 6.0.1-1+0~20231006.53+debian11~1.gbpe91da2 amd64

redis

Redis Support => enabled
Redis Version => 6.0.1
Redis Sentinel Version => 1.0
Available serializers => php, json, igbinary
Available compression => lzf, zstd, lz4

Directive => Local Value => Master Value
redis.arrays.algorithm => no value => no value
redis.arrays.auth => no value => no value
redis.arrays.autorehash => 0 => 0
redis.arrays.connecttimeout => 0 => 0
redis.arrays.distributor => no value => no value
redis.arrays.functions => no value => no value
redis.arrays.hosts => no value => no value
redis.arrays.index => 0 => 0
redis.arrays.lazyconnect => 0 => 0
redis.arrays.names => no value => no value
redis.arrays.pconnect => 0 => 0
redis.arrays.previous => no value => no value
redis.arrays.readtimeout => 0 => 0
redis.arrays.retryinterval => 0 => 0
redis.arrays.consistent => 0 => 0
redis.clusters.cache_slots => 0 => 0
redis.clusters.auth => no value => no value
redis.clusters.persistent => 0 => 0
redis.clusters.read_timeout => 0 => 0
redis.clusters.seeds => no value => no value
redis.clusters.timeout => 0 => 0
redis.pconnect.pooling_enabled => 1 => 1
redis.pconnect.connection_limit => 0 => 0
redis.pconnect.echo_check_liveness => 1 => 1
redis.pconnect.pool_detect_dirty => 0 => 0
redis.pconnect.pool_poll_timeout => 0 => 0
redis.pconnect.pool_pattern => no value => no value
redis.session.locking_enabled => 0 => 0
redis.session.lock_expire => 0 => 0
redis.session.lock_retries => 100 => 100
redis.session.lock_wait_time => 20000 => 20000
redis.session.early_refresh => 0 => 0


bind 127.0.0.1 ::1
protected-mode yes
port 0
tcp-backlog 511
unixsocket /var/run/redis/redis-server.sock
unixsocketperm 770
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis/redis-server.pid
loglevel notice
logfile /var/log/redis/redis-server.log
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
rdb-del-sync-files no
dir /var/lib/redis
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-diskless-load disabled
repl-disable-tcp-nodelay no
replica-priority 100
acllog-max-len 128
maxclients 512
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
oom-score-adj no
oom-score-adj-values 0 200 800
appendonly no
appendfilename “appendonly.aof”
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events “”
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
jemalloc-bg-thread yes


i’ve checked and it is in the redis group.

Thanks for your help

Any help ?

Can you share a few log entries from your nextcloud.log from the period when you saw 500 errors?

Sorry for the late reply, I compared your config and the php-redis package with my test server and everything seems to be identical. The only difference is that I have PHP 8.2 installed. In this context, you could check whether the active PHP version on your system and the php-redis package are on the same version.

Another reason for the internal server error could be some app that is not compatible with Redis. However, I can’t think of any specific app that is known for this, so I’m not sure.

Other than that, I’m running out of ideas, sorry…

So really weird behaviour just happened…

I went back to my config.php to uncomment the lines regarding redis to then check the logs.
The few lines were gone, not even commented, just gone.
So i put them again (without the #) to load the 500 error.
But when i came back to my instance, i could access it and no more message regarding redis in administration panel.
Really weird.
So i guess my problem is solved.
Thanks guys for the help :slight_smile:

2 Likes

@grosJambon33000 @bb77 I’m on a similar system and am getting an Internal Server error when activating Redis for ‘memcache.distributed’. My config file:

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

Furthermore I get the following errors in the admin log:

[PHP] Error: RedisException: No such file or directory at /var/www/nextcloud/lib/private/RedisFactory.php#137

PUT /ocs/v2.php/apps/user_status/api/v1/heartbeat?format=json
from 185.65.135.192 by Linus at 2023-11-06T21:57:17+00:00

RedisException: No such file or directory
RedisException: Redis server went away
...

I can also add that I’m migrating from a ncp instance to a manual installation. Any ideas why Redis would be crashing for some user_status api call?

Try to replace 'host' => '/var/run/redis/redis.sock', with:

'host' => '/var/run/redis/redis-server.sock',

…in your config.php.

If it still doesn’t work please double check everything I posted here.

2 Likes

Thanks @bb77! That was the solution to my problem. :+1:

2 Likes

Hello,

I recently setup a new NC instance, this is my fifth instance in two years and this is the first time I’ve ever seen this error occur.

I am using the following:
Server: Ubuntu 22.04.3
NC version: 28.0.1
Apache2: 2.4.52
PHP version: 8.1.2

Whenever I uncomment 'memcache.distributed' => '\OC\Memcache\Redis',, I get the exact same error as the OP. I have followed everything in post 5 and in post 11 and I still get the same error. As soon as I comment it out again, access is restored.

Within my logs, I see the following odd errors that I’ve never seen before.

PHP error RedisException: No such file or directory at /var/www/nextcloud/lib/private/RedisFactory.php#117
and
Index error RedisException No such file or directory
and
Core error RedisException No such file or directory Exception thrown: RedisException
and
Core error RedisException Redis server went away Exception thrown: RedisException

All above errors always occur in unison.

I’m trying to get this setup for a small business owner that wanted it done before the holidays, so any and all help and recommendations are greatly appreciated.

Cheers.

What are the echoes of

redis-server --version
grep -v '^\s*$\|^\s*#' /etc/redis/redis.conf
tail -n 50 $(awk '/logfile/ {print $NF}' /etc/redis/redis.conf)

Which PHP SAPI speaks to your Apache2?
Find out with this query:

sudo apachectl -tD DUMP_INCLUDES 2>/dev/null | grep -v sites | sed -n '/php.*conf/ s#.*/\([^/]*\)\.conf#\1#p'

What is the echo of

grep -r "redis" /etc/php

With this information it should be easy to find the cause of your problem.

Much luck,
ernolf

1 Like

Thank you for your reply @ernolf. Please find my response below.

redis-server -v 6.0.16
grep -v '^\s*$\|^\s*#' /etc/redis/redis.conf echos

bind 127.0.0.1 ::1
protected-mode yes
port 0
tcp-backlog 511
unixsocket /var/run/redis/redis-server.sock
unixsocketperm 770
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis/redis-server.pid
loglevel notice
logfile /var/log/redis/redis-server.log
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
rdb-del-sync-files no
dir /var/lib/redis
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-diskless-load disabled
repl-disable-tcp-nodelay no
replica-priority 100
acllog-max-len 128
maxclients 512
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
oom-score-adj no
oom-score-adj-values 0 200 800
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
jemalloc-bg-thread yes

The tail of /etc/redis/redis.conf) echos awk: fatal: cannot open file `/etc/redis/redis.conf' for reading: Permission denied. It’s the same message with and without sudo privileges. For what it’s worth, the final 10 lines of the redis config file are all commented out.

sudo apachectl -tD DUMP_INCLUDES 2>/dev/null | grep -v sites | sed -n '/php.*conf/ s#.*/\([^/]*\)\.conf#\1#p' That echos php8.1-fpm as I’d expect.

Last, but not least, your final echo request returns /etc/php/8.1/mods-available/redis.ini:extension=redis.so.

I’m certainly no expert in this, but most of that seems to be the results that I expected. The only odd result to me is the permission denied. I don’t know if it’s worth anything, but /etc/redis is owned by root with 755 permissions and /etc/redis/redis.conf is owned by redis with 640 permissions. The latter of which seem a bit odd to me. Then again, the only thing I know about redis is from the NC documentation.

Thanks for the assistance thus far.

Out of annoyance and some frustration, I deleted my NC and data folders and started again. I even copied the exact same config.php file that I’d copied previously (which came from an older successful install) for the above referenced install and changed all the relevant information. I even compared the two side by side and I couldn’t figure out what the difference was between them. I’m honestly at a loss to understand why it didn’t work the first time and does now.

This is (was) the cause of your issue:

That way your redis server will never start by the systemd mechanism.
It should be

supervised auto

or simply be commented out, since that is the default.

I did not ask for the tail of /etc/redis/redis.conf. I asked for the echo of

wich is the tail of the last 50 lines of the result of

awk '/logfile/ {print $NF}' /etc/redis/redis.conf

in other words, it should give the last 50 lines of the file /var/log/redis/redis-server.log
It is very strange, that awk can not read /etc/redis/redis.conf while grep can :thinking:

YOU expected it, I did not know that and you did not provide that information in your post while it is an important info!

So you did not add the redis config to your /etc/php/8.1/cli/php.ini and /etc/php/8.1/fpm/php.ini:

redis.session.locking_enabled = 1
redis.session.lock_retries = -1
redis.session.lock_wait_time = 10000

OK, On all of my instances, /etc/redis is owned by redis and /etc/redis/redis.conf has 644 permission.

:woozy_face:

Much luck,
ernolf

2 Likes

Thank you. I’d not noticed that, but it makes sense.

Agreed. I tried searching for a little while and could not come up with much.

Whoa, sorry. As I was responding to an existing topic, I was not aware of what “important” info someone else might want.

Yes, you are correct and was a mistake that I made. Which, I ended up discovering later when I set 'memcache.local' => '\\OC\\Memcache\\APCu', and couldn’t get it to work either.

Thank you, this is helpful to know.

Thank you for your detailed assistance.

2 Likes