使用 Mongoose 連接到 MongoDB Atlas 時出現此錯誤。首先,我嘗試使用 Mongo Client 我遇到了同樣的錯誤。然后我切換到貓鼬,它作業正常,但突然停止作業。我已經在網路訪問中添加了“允許來自任何地方”和我的 IP。
MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://docs.atlas.mongodb.com/security-whitelist/
uj5u.com熱心網友回復:
您需要在 Atlas 中添加您的系統 IP,您已經在 Atlas 中創建了您的資料庫。要將多個 IP 地址列入白名單,請轉到 MongoDB Atlas 上的目標集群。接下來,轉到安全選項卡下的網路訪問。在 IP 白名單選項卡上,單擊添加 IP 地址。在白名單條目下手動輸入您的 IP 地址,然后單擊確認。
uj5u.com熱心網友回復:
確保您當前的 IP 地址在錯誤訊息中給出的 Atlas 集群的 IP 白名單中。按照文章https://studio3t.com/knowledge-base/articles/mongodb-atlas-login-ip-whitelisting/ 中給出的步驟進行操作
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/378960.html
