Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sails fails to load when using remote Mongo DB

My Sail app runs when connecting to my local mongo db, but when I try and connect using a db hosted at Modulus, it won't load properly.

I have set the connection properly and tested it via it IDE

connections.js:
    // MONGO DB reference for the database
    cogspeed: {
    adapter   : 'sails-mongo',
    //host      : 'localhost',
    host      : 'novus.modulusmongo.net',
    port      : 27017,
    user      : '*********',
    password  : '***********',
    database  : '**********'
  },

The error I get is:

C:\Projects\gmm\cogspeed>sails lift

info: Starting app...

error: A hook (`orm`) failed to load!
error: Error: failed to connect to [localhost:27017]
    at null.<anonymous> (C:\Projects\gmm\cogspeed\node_modules\sails-mongo\node_modules\mongodb\lib\mongodb\conne
ction\server.js:553:74)
    at EventEmitter.emit (events.js:106:17)
    at null.<anonymous> (C:\Projects\gmm\cogspeed\node_modules\sails-mongo\node_modules\mongodb\lib\mongodb\conne
ction\connection_pool.js:140:15)
    at EventEmitter.emit (events.js:98:17)
    at Socket.<anonymous> (C:\Projects\gmm\cogspeed\node_modules\sails-mongo\node_modules\mongodb\lib\mongodb\con
nection\connection.js:512:10)
    at Socket.EventEmitter.emit (events.js:95:17)
    at net.js:441:14
    at process._tickDomainCallback (node.js:459:13)

Why is Sails still looking at localhost?

Thanks in advance!

like image 334
user2900166 Avatar asked Dec 03 '25 10:12

user2900166


1 Answers

I had the same issue. As it turned out, having more than one connections in connections.js with the same adapter causes this issue. I'm on sails 0.10.5

like image 103
Michael Kork. Avatar answered Dec 06 '25 06:12

Michael Kork.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!