Pymongo 一直在 27017 拒绝连接 [英] Pymongo keeps refusing the connection at 27017
本文介绍了Pymongo 一直在 27017 拒绝连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试运行与 pymongo 的简单连接,但它不断返回连接被拒绝
I am trying to run a simple connection to pymongo but it keeps returning that the connection was refused
这是我尝试过的:
>>>from pymongo import Connection
>>>connection = Connection('localhost',27017)
这是我得到的
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/pymongo-2.0.1_-py2.7-linux i686.egg/pymongo/connection.py", line 348, in __init__
self.__find_node()
File "/usr/local/lib/python2.7/dist-packages/pymongo-2.0.1_-py2.7-linux- i686.egg/pymongo/connection.py", line 627, in __find_node
raise AutoReconnect(', '.join(errors))
pymongo.errors.AutoReconnect: could not connect to localhost:27017: [Errno 111] Connection refused
我该如何解决这个问题?
How do I fix this?
推荐答案
移除 /var/lib/mongodb
sudo rm /var/lib/mongodb/mongod.lock
然后重新启动服务应该可以.例如,在我的 Ubuntu 安装中,重启服务器是这样的:
And then restarting the service should do it. For example, in my Ubuntu installation, restarting the server is something like this:
sudo service mongodb start
这篇关于Pymongo 一直在 27017 拒绝连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文