2017  Kodetalk | Feedback | Privacy Policy | Terms | About

MongoDb connection refused

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/] 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 for my connection, which works to the Mongo shell. Also, I get the admin page in the browser using http://localhost:28017.


(I think it slightly bad form to answer one's own question, but in fact, the answer turns out to be none of those suggested. Nevertheless, my profuse thanks to all of them. When answering a question, one needs to be able to assume it's based on correctly installed and working software. I did not have that.)

I installed MongoDB using the Ubuntu Software Center. It worked from the shell and from the browser as noted elsewhere in this question. However, it did not work from Java (nor from Django either).

The problem, despite what it said in the Java stack trace, was simply "connection refused."

The solution is to install it from proper Mongo sources and not to trust the Ubuntu repository.

(Yes, this also frequently happens to other products obtain from there too, like Eclipse, but you know it's such a nice service that you want to trust it.)

If you want to read how I installed what then worked, check outhttp://www.javahotchocolate.com/tutorials/mongodb.html.

Answer is