简体   繁体   中英

ServerTimeoutError with MongoDB Atlas using PyMongo (running setup code)

I'm running the starter code from MongoDB trying to connect to a cluster I just setup in MongoDB Atlas. I'm getting a Server Selection Timeout Error.

I haven't been able to find anything in the MongoDB troubleshooting docs about this issue.

client = pymongo.MongoClient(
    "mongodb+srv://USR:PWD@cluster0-eoik8.mongodb.net/test?retryWrites=true&w=majority")
db = client.admin
pprint(db.command("serverStatus"))

I've properly encoded the URL (using an online URL encoding service).

The error is

pymongo.errors.ServerSelectionTimeoutError: connection closed,connection closed,connection closed

它不起作用的原因是因为我没有将我的IP地址列入白名单。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM