MongoDb connection refused

Russ Bateman picture Russ Bateman · Jun 27, 2011 · Viewed 67.7k times · Source

This is my first attempt to consume MongoDB. I've got Mongo running:

ps -ef | grep [m]ongo
mongodb  11023  1  0 Jun24 ? 00:00:03 /usr/lib/mongodb/mongod --config /etc/mongodb.conf

And the error comes as the result of doing

Datastore.save( stuff );  // (pseudo code)

The error:

Jun 27, 2011 3:20:29 PM com.mongodb.DBTCPConnector fetchMaxBsonObjectSize
WARNING: Exception determining maxBSON size using0
java.io.IOException: couldn't connect to [russ-elite-book/127.0.1.1:27017] bc:java.net.ConnectException: Connection refused
    at com.mongodb.DBPort._open(DBPort.java:206)
    at com.mongodb.DBPort.go(DBPort.java:94)
    at com.mongodb.DBPort.go(DBPort.java:75)
    at com.mongodb.DBPort.findOne(DBPort.java:129)
    at com.mongodb.DBPort.runCommand(DBPort.java:138)
    ...

Note that I'm using 127.0.0.1:27017 for my connection, which works to the Mongo shell. Also, I get the admin page in the browser using http://localhost:28017.

Profuse thanks for any and all ideas!

Answer

nids picture nids · Oct 16, 2012

I ran into the same issue because I upgraded my mongo using brew. To fix this issue. Look for the conf file(which might not be located in the bin directory where you start your mongodb from)

/usr/local/Cellar/mongodb-2.2.whatever/mongod.conf, and comment out the "bind_ip" property.