无法与pymongo建立联系

时间:2014-06-17 17:01:47

标签: python pymongo

尝试与pymongo建立连接并收到此错误:

>>> from pymongo import Connection
>>> con = Connection('localhost')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/pymongo/connection.py", line 236, in __init__
    max_pool_size, document_class, tz_aware, _connect, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pymongo/mongo_client.py", line 369, in __init__
    raise ConnectionFailure(str(e))
pymongo.errors.ConnectionFailure: [Errno 111] Connection refused

1 个答案:

答案 0 :(得分:0)

Connection refused表示您没有运行MongoDB实例。

首先,你应该开始吧。 例如,对于Ubuntu,它将是:

sudo service mongod start

但在此之前,请确保安装了mongodb。