我在尝试连接到mongolab时遇到此错误。我正在使用pymongo-2.8,如其他一些答案所述。
connection=MongoClient("mongodb://usr:pass@host:port/data")
堆栈跟踪:
Traceback (most recent call last):
File "C:\chrome_addon\database_update.py", line 5, in <module>
connection=MongoClient("mongodb://user:pass@host:port/data")
File "C:\Python27\lib\site-packages\pymongo\mongo_client.py", line 377, in __init__
raise ConnectionFailure(str(e))
pymongo.errors.ConnectionFailure: [Errno 10061] No connection could be made because the target machine actively refused it
[Finished in 1.6s with exit code 1]
我也试过用命令行访问它,它失败了。
mongo ds031711.mongolab.com:31711/data -u <dbuser> -p <dbpassword>
堆栈跟踪:
MongoDB shell version: 3.0.5
connecting to: ds031711.mongolab.com:31711/data
2015-10-02T10:40:21.662+0530 W NETWORK Failed to connect to 54.159.76.238:31711
, reason: errno:10061 No connection could be made because the target machine act
ively refused it.
2015-10-02T10:40:21.670+0530 E QUERY Error: couldn't connect to server ds0317
11.mongolab.com:31711 (54.159.76.238), connection attempt failed
at connect (src/mongo/shell/mongo.js:181:14)
at (connect):1:6 at src/mongo/shell/mongo.js:181
exception: connect failed
URI和用户名,密码正确无误。