garima
garima

Reputation: 5244

How to connect meteor and mongoDB on separate machines

I want to connect the Mongo DB on the other server with meteor on my local machine.

Any help appreciated.I am new to meteor.

error on running meteor

Can't start Mongo server. MongoDB had an unspecified uncaught exception. This can be caused by MongoDB being unable to write to a local database. Check that you have permissions to write to .meteor/local. MongoDB does not support filesystems like NFS that do not allow file locking.

Upvotes: 0

Views: 376

Answers (1)

Ethaan
Ethaan

Reputation: 11376

On the meteor app machine, on the server side use this piece of code.

 if(Meteor.isServer){
    Meteor.startup(function () {
       var myDatabase = new MongoInternals.RemoteCollectionDriver("<mongo url>");
       MyCollection = new Mongo.Collection("collection_name", { _driver: myDatabasee });
     });
   }

The only you need to know its the name of the url <mongo url> it could be something like mongodb://127.0.0.1:27017/local or meteor

Upvotes: 1

Related Questions