redis / redis/node-redis

createClient trying to connect with localhost even though URL is for docker's redis instance

Open
#2,416 20 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description

I am trying to create a client with URL redis://${process.env.REDIS_HOST}:${process.env.REDIS_PORT}, and sending REDIS_HOST=rediss and REDIS_PORT=6379, but still it is trying to connect with localhost

redis is running in docker, tested the connection, its working
also have other instance of ioredis using same connection, it is able to connect

Node.js Version

v19.6.0

Redis Server Version

7.0.5

Node Redis Version

4.6.4

Platform

Linux

Logs
web       | Error: connect ECONNREFUSED 127.0.0.1:6379
web       |     at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) {
web       |   errno: -111,
web       |   code: 'ECONNREFUSED',
web       |   syscall: 'connect',
web       |   address: '127.0.0.1',
web       |   port: 6379
web       | }

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 createClient call and inspect how the REDIS_HOST and REDIS_PORT environment values are assembled into the URL. Reproduce with Node.js v19.6.0, Redis 7.0.5, and node-redis 4.6.4, then verify that the client connects to the configured Docker Redis endpoint rather than localhost.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, redis, typescript
Domain
backend, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.