title: Error: Redis connection to 0.0.0.0:6379 failed - connect ECONNREFUSED 0.0.0.0:6379
body: <p>I have been trying to build the classical voting app. But my redis and mongodb are giving same error. I have to connect my redis to my node app and i have tried the following:</p>
  <pre><code>//redis
  const redisoption = {
      host: &quot;redis&quot;,
      port: 6379
  };
  </code></pre>
  <p>.</p>
  <pre><code>//redis
  const redisoption = {
      host: &quot;0.0.0.0&quot;,
      port: 6379
  };
  </code></pre>
  <p>docker-compose.yml</p>
  <pre><code>version: &quot;3&quot;
  </code></pre>
  <p>services:</p>
  <pre><code>vote:
      image: adityagaddhyan/voting-app
      ports: 
          - &quot;3000:3000&quot;
      depends_on:
          - redis
      networks:
          - front-end
          - back-end
      volumes: 
          - ./vote:/app
  result:
      image: adityagaddhyan/voting-result
      ports: 
          - &quot;3011:3011&quot;
      depends_on:
          - mongodb
      networks: 
          - back-end
          - front-end
      volumes: 
          - ./result:/app
  
  worker:
      image: adityagaddhyan/service-worker
      depends_on: 
          - redis
          - mongodb
      networks: 
          - back-end
      volumes: 
          - ./worker:/app
  redis:
      image : redis
      command: [&quot;redis-server&quot;, &quot;--bind&quot;, &quot;0.0.0.0&quot;, &quot;--port&quot;, &quot;6379&quot;
      ports: 
          - &quot;6379:6379&quot;
      networks: 
          - back-end
      volumes: 
          - ./redis:/app
  mongodb:
      image: mongo
      ports:
          - &quot;27017:27017&quot;
      volumes: 
          - ./db:/app
  </code></pre>
  <p>volumes:
  db-data:</p>
  <p>networks:
  front-end:
  back-end:</p>
  <p>I have tried all sort of combination.
  I am majorily getting two kind of error.
  if i use <code>host: &quot;0.0.0.0&quot;,</code> i get</p>
  <pre><code>    Error: Redis connection to 0.0.0.0:6379 failed - connect ECONNREFUSED 0.0.0.0:6379
  vote_1     |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
  vote_1     | Emitted 'error' event on RedisClient instance at:
  vote_1     |     at RedisClient.on_error (/usr/src/app/node_modules/redis/index.js:341:14)
  vote_1     |     at Socket.&lt;anonymous&gt; (/usr/src/app/node_modules/redis/index.js:222:14)
  vote_1     |     at Socket.emit (events.js:315:20)
  vote_1     |     at emitErrorNT (internal/streams/destroy.js:92:8)
  vote_1     |     at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
  vote_1     |     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  vote_1     |   errno: 'ECONNREFUSED',
  vote_1     |   code: 'ECONNREFUSED',
  vote_1     |   syscall: 'connect',
  vote_1     |   address: '0.0.0.0',
  vote_1     |   port: 6379
  vote_1     | }
  </code></pre>
  <p>and if i use <code>host:redis</code>, i get:</p>
  <pre><code>    Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
  worker_1   |     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1141:16)
  worker_1   | Emitted 'error' event on RedisClient instance at:
  worker_1   |     at RedisClient.on_error (/usr/src/app2/node_modules/redis/index.js:341:14)
  worker_1   |     at Socket.&lt;anonymous&gt; (/usr/src/app2/node_modules/redis/index.js:222:14)
  worker_1   |     at Socket.emit (events.js:315:20)
  worker_1   |     at emitErrorNT (internal/streams/destroy.js:92:8)
  worker_1   |     at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
  worker_1   |     at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  worker_1   |   errno: 'ECONNREFUSED',
  worker_1   |   code: 'ECONNREFUSED',
  worker_1   |   syscall: 'connect',
  worker_1   |   address: '127.0.0.1',
  worker_1   |   port: 6379
  worker_1   | }
  vote_1     | /usr/src/app/app.js:28
  vote_1     |     host: back-end,
  vote_1     |           ^
  </code></pre>
  <p>I am new to docker and unable to solve this problem. please help.</p>