简体   繁体   English

pymongo.errors.ServerSelectionTimeoutError:本地主机:27017:[Errno 61]连接被拒绝

[英]pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 61] Connection refused

I am learning to use pymongo, but I get stuck on the intro code from this website https://realpython.com/introduction-to-mongodb-and-python/#sql-vs-nosql : 我正在学习使用pymongo,但是我陷入了该网站https://realpython.com/introduction-to-mongodb-and-python/#sql-vs-nosql的介绍代码中:

from pymongo import MongoClient

client = MongoClient('localhost', 27017)
db = client.pymongo_test

posts = db.posts
post_data = {'title': 'Python and MongoDB'}
result = posts.insert_one(post_data)

After the last line, I get the error in the header. 最后一行之后,我在标题中得到了错误。 I have no experience with databases, so I have no idea where to start debugging this. 我没有数据库方面的经验,所以我不知道从哪里开始调试它。

I am using Python 3.7.3, pymongo 3.7.2 and mongodb 4.0.3 on a Mac OS X. 我在Mac OS X上使用Python 3.7.3,pymongo 3.7.2和mongodb 4.0.3。

刚发现-我认为只需在Anaconda上安装mongodb软件包就足够了,但是我必须使用brew正确安装MongoDB。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] 连接被拒绝 - pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] 连接拒绝 django 到 heroku - pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused django to heroku Mongodb pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection denied, Timeout: 30s, - Mongodb pymongo.errors.ServerSelectionTimeoutError: localhost:27017: [Errno 111] Connection refused, Timeout: 30s, pymongo.errors.ServerSelectionTimeoutError:localhost:27017:[WinError 10061]无法建立连接,因为目标机器主动拒绝 - pymongo.errors.ServerSelectionTimeoutError:localhost:27017:[WinError 10061]No connection could be made because the target machine actively refused it 连接到 mongo 图集给出 pymongo.errors.ServerSelectionTimeoutError: localhost:27017 - Connecting to mongo atlas gives pymongo.errors.ServerSelectionTimeoutError: localhost:27017 pymongo.errors.ServerSelectionTimeoutError - pymongo.errors.ServerSelectionTimeoutError 烧瓶 - pymongo.errors.ServerSelectionTimeoutError - Flask - pymongo.errors.ServerSelectionTimeoutError pymongo.errors.ServerSelectionTimeoutError:db:27017:超时,超时:30s, - pymongo.errors.ServerSelectionTimeoutError: db:27017: timed out, Timeout: 30s, pymongo.errors.ServerSelectionTimeoutError: RepliceSetNoPrimary - MongoDB Atlas - pymongo.errors.ServerSelectionTimeoutError: RepliceSetNoPrimary - MongoDB Atlas Pymongo pymongo.errors.ServerSelectionTimeoutError 使用示例代码时 - Pymongo pymongo.errors.ServerSelectionTimeoutError when using example code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM