Itay Maman
Itay Maman

Reputation: 30723

Cannot connect to mongo on heroku due to missing replicaset parameter

I have a node.js app running on heroku. I am trying to update my mongodb module to "~2.0.3". In my local dev. environment everything is working fine. However, when I deploy the to Heroku I get a "replicaSet parameter must be set" error which did not fire with earlier version of the mongodb module. I am not how to go about it. In particular, I have no idea where can I find the name of that replicaSet.

Here's a transcript of a node REPL session showing the problem:

$ heroku run node --app my-app
Running `node` attached to terminal... up, run.8299
>var mongo = require('mongodb');
undefined
> var a = {}
undefined
> process.env.MONGOLAB_URI
'mongodb://UUUUU:PPPPP.mongolab.com:45970/heroku_appNNNNNNN'
> mongo.MongoClient.connect(process.env.MONGOLAB_URI, function (err, db) { 
     a.err = err; a.db = db; console.log('CALLED'); });
undefined
> CALLED

undefined
> a
{ err: 
   { [MongoError: replicaSet parameter must be set]
     name: 'MongoError',
     message: 'replicaSet parameter must be set' },
  db: null }
> 

One more thing: when I access the DB through the web interface I see only two system collections: system.indexes and system.users. To the best of my understanding this suggests that my DB is not part of a replicaSet which makes the whole thing weird.

Upvotes: 1

Views: 324

Answers (1)

Itay Maman
Itay Maman

Reputation: 30723

This is indeed a problem in 2.0.3. It was solved in 2.0.4 by this pull request.

Bottom line: If you encounter "replicaSet parameter must be set" error in 2.0.3, upgrade to 2.0.4.

Upvotes: 1

Related Questions