【发布时间】:2021-12-14 21:16:11
【问题描述】:
代码
client = pymongo.MongoClient("mongodb+srv://username:password@cluster0.zcui8.mongodb.net/db?retryWrites=true&w=majority&ssl=true&ssl_cert_reqs=CERT_NONE")
db = client["db"]
#this gives the error
res = list(db.listings.find({}).limit(15).sort([('$natural',-1)]))
错误:
pymongo.errors.ServerSelectionTimeoutError: No replica set members found yet
我在分配变量res 的行中收到此错误。
在我的机器上运行它时我没有得到这个错误,但是当我在服务器上运行它时我得到了错误。
【问题讨论】:
-
您是否将应用服务器的新 IP 地址添加到 Atlas 上的允许列表中?
-
不,我添加了
0.0.0.0,所以每个人都应该能够连接。
标签: python database mongodb networking pymongo