title: Connecting couchdb container from another container
body: <p>I'm trying to connect to my couchdb container from nodejs app which is running in another container. My docker-compose file is like this;</p>
  
  <pre><code>version: '3.1'
  services:
      couchdb:
          image: couchdb
          container_name: my-db
          ports:
              - 5984:5984
          environment:
              COUCHDB_USER: admin
              COUCHDB_PASSWORD: password
      api:
         image: my-api
         container_name: my-api
         build: .
         command: npm run dev
         ports:
             - 8080:8080
         depends_on:
             - couchdb
         links:
             - couchdb
  </code></pre>
  
  <p>But I always get an error which says;</p>
  
  <pre><code>Error: connect ECONNREFUSED 172.19.0.2:5984
      at Object._errnoException (util.js:1003:13)
      at _exceptionWithHostPort (util.js:1024:20)
      at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1195:14)
  </code></pre>
  
  <p>I saw this post mentioning the same issue;
  <a href="https://stackoverflow.com/questions/37484726/how-to-map-database-from-couchdb-container-to-another-containers-webapp-in-same">how to map database from couchdb container to another containers webapp in same docker-compose file</a></p>
  
  <p>When I try that, I'm getting the same error.
  New docker compose file;</p>
  
  <pre><code>version: '3.1'
  services:
      couchdb:
          image: couchdb
      container_name: my-db
      ports:
          - 5984:5984
      environment:
          COUCHDB_USER: admin
          COUCHDB_PASSWORD: password
  api:
      image: my-api
      container_name: my-api
      build: .
      command: npm run dev
      ports:
          - 8080:8080
      depends_on:
          - couchdb
      links:
          - couchdb
      environment:
          DB_URL: http://admin:password@couchdb:5984
  </code></pre>
  
  <p>Still the same error..</p>
  
  <p>I'm trying to connect the couchdb container with its service name ('couchdb') in nodejs side. I also checked if the containers are on the same network. Both are on a network named 'my_default' using bridge driver.</p>
  
  <p>When I try to connect to db from local running nodejs app, there is no problem.</p>
  
  <p>Is there anything that I forgot?</p>