title: Unable to connect with mongodb localhost:27017
body: <p>I trying to connect with mongodb using nodejs server and express. My mongoose version is 5.2.0 and mongodb version is 4.0. I have tried multiple ways to connect with mongodb but the mongod server just keeps listening and do not connect with the server and no database gets created. I have tried connecting with mongoose and also with mongoclient but mongod in cmd just keeps listening and do not get connected. here is my server code </p>
  
  <pre><code>var express = require('express');
  var mongoose = require('mongoose');
  
  var User = require('./models/user');
  var app = express();
  
  
  var db = mongoose.connect("mongodb://localhost:27017/server", { useNewUrlParser: true }, function(err, response) {
      if(err) {
          console.log('There is error in connecting with mongodb');
      }
      console.log('Connection has been established.');
  })
  </code></pre>
  
  <p>mongod in cmd</p>
  
  <pre><code>2019-01-13T23:56:05.690+0500 I CONTROL  [initandlisten]
  2019-01-13T23:56:05.691+0500 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
  2019-01-13T23:56:05.691+0500 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server.
  2019-01-13T23:56:05.692+0500 I CONTROL  [initandlisten] **          Start the server with --bind_ip &lt;address&gt; to specify which IP
  2019-01-13T23:56:05.692+0500 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
  2019-01-13T23:56:05.693+0500 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
  2019-01-13T23:56:05.693+0500 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
  2019-01-13T23:56:05.694+0500 I CONTROL  [initandlisten]
  2019-01-13T23:56:06.073+0500 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data'
  2019-01-13T23:56:06.078+0500 I NETWORK  [initandlisten] waiting for connections on port 27017
  </code></pre>
  
  <p>mongo in cmd another window</p>
  
  <pre><code>C:\Program Files\MongoDB\Server\4.0\bin&gt;mongo
  MongoDB shell version v4.0.2
  connecting to: mongodb://127.0.0.1:27017
  MongoDB server version: 4.0.2
  Server has startup warnings:
  2019-01-11T20:05:57.109+0500 I CONTROL  [initandlisten]
  2019-01-11T20:05:57.113+0500 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
  2019-01-11T20:05:57.114+0500 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
  2019-01-11T20:05:57.114+0500 I CONTROL  [initandlisten]
  ---
  
  ---
  &gt;
  </code></pre>