Can’t connect redis with app on different container

  docker, node.js, redis

I’m new in Docker, and want to dockerize my node app. My Node App using Redis, and work properly with Redis out of Docker. I have 2 Containers, one is called redis, and it’s run properly. The problem is, when I run my App Container called billing-api, it returned an error,

> [email protected] start /app

> node ./bin/www


throw er; // Unhandled 'error' event


Error: connect ECONNREFUSED

at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1148:16)

Emitted 'error' event on RedisClient instance at:

at RedisClient.on_error (/app/node_modules/redis/index.js:342:14)

at Socket.<anonymous> (/app/node_modules/redis/index.js:223:14)

at Socket.emit (events.js:375:28)

at emitErrorNT (internal/streams/destroy.js:106:8)

at emitErrorCloseNT (internal/streams/destroy.js:74:3)

at processTicksAndRejections (internal/process/task_queues.js:82:21) {

errno: -111,


syscall: 'connect',

address: '',

port: 6379



npm ERR! errno 1

npm ERR! [email protected] start: `node ./bin/www`

npm ERR! Exit status 1

npm ERR!

npm ERR! Failed at the [email protected] start script.

npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

npm ERR! /root/.npm/_logs/2021-07-23T04_18_32_107Z-debug.log

It says that is refused the connection. But, when I use RedisInsight, it can be accessed (I could see any information normally like when using Memurai),


When checking with docker ps, there is>6379/tcp in PORTS of my running Redis Container, so I thought it was exposed in 6379.

Here is my Dockerfile of billing-api,

FROM node:14

# Create app directory
RUN mkdir -p /app

# Install app dependencies
COPY package.json /app/
RUN npm install

# Bundle app source
COPY . /app

CMD [ "npm", "start" ]

I’m not using docker-compose, use links in Dockerfile, etc., I don’t know, but next time this container will run on Kubernetes, and I just want it running right now.

I thought the problem is something about Network, VPN, or Proxies, because I use OpenVPN to connect to my company network. But I’m not changing anything in Docker Settings->Resources.


Source: Docker Questions