redis / redis/node-redis

When TLS is not enabled, library tying to connect to local host

Open
#2,114 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Pending Author Input
Dominant language
TypeScript
Stars
17.6k
Forks
2k
Avg merge
2d 3h
Merged PRs (30d)
40

Description

I'm not sure whether this is a bug or not. I have spun up a docker Redis cluster (No TLS) in my local Docker environment. I'm trying to connect to the cluster with the following configurations in my Node application (another container). But, what I can see in my node application logs is,
"Redis Cluster Error Error: connect ECONNREFUSED 127.0.0.1:6379".
It seems this library is trying to connect to the localhost. But I have tried with a different library and it worked for the Redis Clustor.
Here are my configs.

const cluster = createCluster({ 
            rootNodes: [
                { url: 'redis://173.18.0.2:6379' },
                { url: 'redis://173.18.0.3:6379' },
                { url: 'redis://173.18.0.4:6379' }
            ],
            nodeAddressMap: {
                'redis://173.18.0.2:6379': { host: 'redis_1', port: 6379 },
                'redis://173.18.0.3:6379': { host: 'redis_2', port: 6379 },
                'redis://173.18.0.4:6379': { host: 'redis_3', port: 6379 }
            },
            defaults: {
                socket: {
                    host: 'redis',
                    connectTimeout: 5000,
                    tls: false
                },
                password: ''
            },
            useReplicas: true
        });

Am I missing any config here? Why does it try to connect to localhost?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the createCluster configuration shown in the issue, especially rootNodes, nodeAddressMap, and the socket defaults, and reproduce it with the described Docker Redis cluster. Trace which addresses are returned and used after the initial connection; done means the client connects to the mapped redis_ hosts instead of attempting 127.0.0.1:6379.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, redis, typescript
Domain
backend, databases, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.