title: How to resolve Mongoose Connect UNKNOWN?
body: <p>I am building a REST API service with Node, Express and MongoDB. I installed MongoDB and it runs normally on my PC on localhost:27017. I can add collections and read them. In my app.js file I have this setup</p>
  <pre class="lang-js prettyprint-override"><code>var express = require('express');
  var mongoose = require('mongoose');
  var bodyParser = require('body-parser');
      
  mongoose.connect('mongodb://127.0.0.1:27017/bookAPI');
      
  var db = mongoose.connection;
  db.on('error', console.error.bind(console, 'connection error:'));
  db.once('open', function callback () {
      console.log(&quot;h&quot;);
  });
      
  var app = express();
  app.use(bodyParser.urlencoded({ extended: true }));
  app.use(bodyParser.json());
      
  var port = process.env.PORT || 3000;
  app.use('/api', require('./routes/api.js'));
      
  app.listen(port, function() {
      console.log('Running on port ' + port);
  });
  </code></pre>
  <p>I always get an error- <code>MongoError - cannot connect UNKNOWN</code>.
  I've searched for hours and didn't find any solution. How can I fix it so it can connect to MongoDB, which is working properly...?</p>