MongoDb连接被拒绝 [英] MongoDb connection refused

查看:837
本文介绍了MongoDb连接被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次尝试使用MongoDB.我让Mongo运行了:

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

错误是这样做的结果

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

错误:

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)
    ...

请注意,我正在使用 127.0.0.1:27017 进行连接,该连接适用于Mongo shell.另外,我使用 http://localhost:28017 在浏览器中获得管理页面.

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.

对任何想法表示感谢!

推荐答案

(我认为回答自己的问题有点差劲,但实际上,答案没有一个建议.尽管如此,但我非常感谢回答一个问题时,一个人必须能够假定它基于正确安装且正在运行的软件.我没有那个.)

(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.)

我使用Ubuntu软件中心安装了MongoDB.如问题中其他地方所述,它是从外壳程序和浏览器运行的.但是,它不适用于Java(也不适用于Django).

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).

尽管它在Java堆栈跟踪中说了什么,但问题只是连接被拒绝".

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

解决方案是从正确的Mongo来源安装它,而不是信任Ubuntu存储库.

(是的,从Eclipse那里获得的其他产品也经常发生这种情况,但是您知道它是一种很好的服务,因此您要信任它.)

(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.)

如果您想阅读我如何安装然后工作的软件,请查看 http://www.javahotchocolate.com/tutorials /mongodb.html .

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

这篇关于MongoDb连接被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆