0

I am running Ubuntu server 20.04 LAMP, with Redis 5.0.7.

Problem:
When a unix socket has been configured with port 0 Redis refuses all connections.

basic /etc/redis/redis.conf:

# create a unix domain socket to listen on
unixsocket /var/run/redis/redis.sock
# set permissions for the socket
unixsocketperm 775
bind 127.0.0.1
daemonize yes
stop-writes-on-bgsave-error no
rdbcompression yes
# maximum memory allowed for redis
maxmemory 50M
# how redis will evice old objects - least recently used
maxmemory-policy allkeys-lru
# tells redis to ignore TCP ports
port 0 
#creates pidfile
pidfile /run/redis/redis-server.pid

Socket:

# ls -lh /var/run/redis
total 4.0K
-rw-rw---- 1 redis redis 5 Jul 30 18:23 redis-server.pid
srwxrwxr-x 1 redis redis 0 Jul 30 18:23 redis.sock

Listening Port:

# ps aux | grep redis
redis       4912  0.1  0.0  50192  3972 ?        Ssl  18:23   0:01 /usr/bin/redis-server 127.0.0.1:0
root        6395  0.0  0.0   6432   592 pts/1    S+   18:36   0:00 grep --color=auto redis


Connections Refused:

# redis-cli
Could not connect to Redis at 127.0.0.1:6379: Connection refused
not connected> quit

and

# redis-cli -h 127.0.0.1 -p 0 
Could not connect to Redis at 127.0.0.1:0: Connection refused

Firewall completely disabled.

Any ideas?

Maestro223
  • 203
  • 2
  • 13
  • What is the result of `netstat -anp|grep LISTEN` executed as root? – Romeo Ninov Jul 30 '22 at 10:42
  • Only redis related it `unix 2 [ ACC ] STREAM LISTENING 85256 4912/redis-server 1 /var/run/redis/redis.sock` – Maestro223 Jul 30 '22 at 10:45
  • So redis do not listen on TCP port. How do you expect to connect? Try `redis-cli -s /var/run/redis/redis.sock` – Romeo Ninov Jul 30 '22 at 10:52
  • Thanks for the tip... I was connecting incorrectly tcp / socket.. Additionally my user trying to connect doesn't have sufficient permissions, whereas root does. This helped a lot a full solution from here should be easy. – Maestro223 Jul 30 '22 at 11:02

1 Answers1

1

From comments I see redis do not listen to TCP port but only use socket. In such case the connection should be done with command

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

The line

redis-cli -h 127.0.0.1 -p 0 

connect to IP and port. And you can't use port 0, AFAIK it's reserverd

Romeo Ninov
  • 5,263
  • 4
  • 20
  • 26