9

I have following config:

  "mongoose": {
    "url": "mongodb://127.0.0.1:27017/chat",
    "options": {
      "server": {
        "socketOptions": {
          "keepAlive": 1
        }
      }
    }
  }

And connect to my DB

mongoose.connect(config.get('mogoose:url'), config.get('mongoose:options'))

But I'm getting such error:

node_modules/mongoose/node_modules/mongodb/lib/server.js:236
        process.nextTick(function() { throw err; })
                                      ^
Error: getaddrinfo ENOTFOUND undefined undefined:27017
    at errnoException (dns.js:27:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:78:26)

I have already checked answers for simular question.

I'm quite new in Mongo, but following code works fine using native driver:

var MongoClient = require('mongodb').MongoClient
  , format = require('util').format;

MongoClient.connect('mongodb://127.0.0.1:27017/chat', function(err, db) {
  if (err) throw err;
//blabla
}

So answers for that question are not actual in my case.

Community
  • 1
  • 1
mondayguy
  • 973
  • 2
  • 12
  • 34

1 Answers1

12

Problem in your code is that you typo here config.get('mogoose:url'). You missed a n in mongoose. Thats why you trying connect to undefined:27017

Alexey B.
  • 11,965
  • 2
  • 49
  • 73