Reputation: 3680
The script inside VM 192.168.26.103 is trying to connect to MongoDB on VM 192.168.26.104
But getting 'ECONNREFUSED' error
var mongoose = require('mongoose');
var dbConnect = mongoose.createConnection('mongodb://192.168.26.104:27017/test', {
db: { safe: true }
})
Error:
{ name: 'MongoError', message: 'connect ECONNREFUSED' }
Upvotes: 2
Views: 2131
Reputation: 3680
I solved the issue myself. Posting the solution below so someone might find helpfull.
In remote MongoDB server 192.168.26.104 i changed the bind_ip and now my script can connect to it successfully
/etc/mongod.conf
From bind_ip = 127.0.0.1
To bind_ip = 192.168.26.104
service mongod restart
Upvotes: 5