我在我的瓶子里安装了pymongo。我试图使用它,但出现以下错误:
connection = Connection()
---------------------------------------------------------------------------
ConnectionFailure Traceback (most recent call last)
<ipython-input-9-609d5cb538f5> in <module>()
----> 1 connection = Connection()
/home/python/BENV/local/lib/python2.7/site-packages/pymongo/connection.pyc in __init__(self, host, port, max_pool_size, network_timeout, document_class, tz_aware, _connect, **kwargs)
234
235 super(Connection, self).__init__(host, port,
--> 236 max_pool_size, document_class, tz_aware, _connect, **kwargs)
237
238 def __repr__(self):
/home/python/BENV/local/lib/python2.7/site-packages/pymongo/mongo_client.pyc in __init__(self, host, port, max_pool_size, document_class, tz_aware, _connect, **kwargs)
367 except AutoReconnect, e:
368 # ConnectionFailure makes more sense here than AutoReconnect
--> 369 raise ConnectionFailure(str(e))
370
371 if username:
ConnectionFailure: [Errno 111] Connection refused
我为什么会遇到这个错误?我该如何修复它?在
当您不指定要连接的主机和端口时,就像不向Connection传递任何内容一样
connection = Connection()
驱动程序试图连接到本地主机上的端口27017。在由于失败,它强烈建议您没有在pymongo正在侦听端口27017的同一台计算机上运行
mongod
进程。在如果您已经有了要连接到的MongoDB服务器,则必须指定其位置-主机和传递给连接的端口。在
相关问题 更多 >
编程相关推荐