Skip to content

Unable to connect to redis that listening on IPv6 interface #512

@morawskim

Description

@morawskim

Hello,

The redis-commander has problem with connecting to redis that listening on IPv6 interface.

I deployed rediscommander using image rediscommander/redis-commander:latest (docker.io/rediscommander/redis-commander@sha256:19cd0c49f418779fa2822a0496c5e6516d0c792effc39ed20089e6268477e40a ). When I tried to connect to configured redis server (added by env variable) in logs I noticed errors:

MaxRetriesPerRequestError: Reached the max retries per request limit (which is 20). Refer to "maxRetriesPerRequest" option for details.                                           
    at Socket.<anonymous> (/redis-commander/node_modules/ioredis/built/redis/event_handler.js:176:37)                                                                   
    at Object.onceWrapper (events.js:421:26)
    at Socket.emit (events.js:314:20)
    at TCP.<anonymous> (net.js:675:12)
setUpConnection (R:redis:6379:0) Redis error Error: getaddrinfo ENOTFOUND redis                                                                                                                            
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)

I changed my deployment manifest. I added:

#...
      securityContext:
        runAsUser: 0

After this change I was able to exec to running pod with root privileges.
I installed redis.
Using redis-cli -h redis I was able to connect to redis instance and call ping command.

I checked source code and i found this -

family: 4

Object.assign(redisOpts, {
    port: clientConfig.port,
    host: clientConfig.host,
    path: clientConfig.path,
    family: 4
});

I changed the value of family property to 6.
I ran ps -ef to see running commands.
I decided to ran a new instane of redis-commander on a different port: /usr/bin/node ./bin/redis-commander --port 8082 --redis-port tcp://[fd2e:565e:ab48::XXXX]:6379.
I used kubectl port-forward to connect to a new redis-commander instance and everything worked - I connected to redis and I saw all my keys in db.

At the moment neither minikube (https://minikube.sigs.k8s.io/docs/faq/#does-minikube-support-ipv6) nor microk8s (canonical/microk8s#1343) support IPv6 stack. So I cannot prepare example.
I have access to k8s cluster which run on ipv6 stack, so I am able to test fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions