2

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' }
3
  • Try to connect in shell(command prompt). if its not k ,then there is some problem in configuration. Commented Oct 12, 2015 at 12:08
  • @Subburaj i can successfully ssh to that server and run mongo command Commented Oct 12, 2015 at 12:09
  • Whether mongo is running on default port in server? Commented Oct 12, 2015 at 12:16

1 Answer 1

5

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
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.