Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379 only Docker Container

  Kiến thức lập trình

config: nestjs, docker, redis(local)

when i run ‘npm run start:dev’, pop ‘connected redis’.
However, when I build a Docker file and launch a container, once Redis is connected, an error occurs.

connected redis
[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16)
[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16)
[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16)
[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16)
[ioredis] Unhandled error event: Error: connect ECONNREFUSED 127.0.0.1:6379
    at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16)
...

i already check REDIS_HOST, REDIS_PORT.
The key is that once the connection is successful, an error occurs.

Does anyone know?

pop ‘connected redis’ and dont show ECONNREFUSED error….

New contributor

노정우 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT