title: How do I connect my mongo database to my node app with this mongoDB connection string using docker-compose?
body: <p>This is a part of my node app</p>
  
  <pre><code>app.configure('development', function() {
    app.set('db-uri', 'mongodb://localhost/nodepad-development');
    app.use(express.errorHandler({ dumpExceptions: true }));
    app.set('view options', {
      pretty: true
    });
  });
  
  app.configure('test', function() {
    app.set('db-uri', 'mongodb://localhost/nodepad-test');
    app.set('view options', {
      pretty: true
    });  
  });
  
  app.configure('production', function() {
    app.set('db-uri', 'mongodb://localhost/nodepad-production');
  });
  </code></pre>
  
  <p>Edited to </p>
  
  <pre><code>app.set('db-uri', 'mongodb://mongoDB:27017/nodepad-development');
  </code></pre>
  
  <p>Still the same error.
  I have already created container for my node app which runs on local host but I am unable to connect it to another mongo container due to which I cannot do POST requests to the app.</p>
  
  <p>This is my docker compose file</p>
  
  <pre><code>version: '3'
  services:
    apptest:
      container_name: apptest
      restart: always
      image: ekamzf/nodeapp:1.1
      ports:
        - '8080:8080
      depends_on:
            - mongoDB
  
    mongoDB:
      container_name: mongoDB
      image: mongo
      volumes:
        - ./data:/usr/src/app
      ports:
        - '27017:27017'  
  </code></pre>
  
  <p>And the error I get when I try to register account details in my node app is</p>
  
  <pre><code>Error: Timeout POST /users
      at null._onTimeout (/usr/src/app/node_modules/connect-timeout/index.js:12:22)
      at Timer.listOnTimeout [as ontimeout] (timers.js:110:15)
  </code></pre>
  
  <p>What am I missing?
  Basically, how should I connect this type of code with mongodb anyway ?
  What's the role of 'db-uri'?</p>