[英]MongoDB network keeps throwing this error
我在嘗試連接到我的 MongoDB 數據庫時遇到錯誤,這是 repo 。
這是我在運行代碼時遇到的錯誤 -
MongoServerSelectionError: connection <monitor> to 52.20.9.178:27017 closed
at Timeout._onTimeout (C:\Users\PC\Downloads\SkyCrypt-development\SkyCrypt-development\node_modules\mongodb\lib\sdam\topology.js:306:38)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7) {
reason: TopologyDescription {
type: 'Unknown',
servers: Map(1) {
'cluster0-shard-00-00.kx9xv.mongodb.net:27017' => ServerDescription {
_hostAddress: HostAddress {
isIPv6: false,
host: 'cluster0-shard-00-00.kx9xv.mongodb.net',
port: 27017
},
address: 'cluster0-shard-00-00.kx9xv.mongodb.net:27017',
type: 'Unknown',
hosts: [],
passives: [],
arbiters: [],
tags: {},
minWireVersion: 0,
maxWireVersion: 0,
roundTripTime: -1,
lastUpdateTime: 7396352,
lastWriteDate: 0,
error: MongoNetworkError: connection <monitor> to 52.20.9.178:27017 closed
at Connection.onClose (C:\Users\PC\Downloads\SkyCrypt-development\SkyCrypt-development\node_modules\mongodb\lib\cmap\connection.js:138:19)
at Socket.<anonymous> (C:\Users\PC\Downloads\SkyCrypt-development\SkyCrypt-development\node_modules\mongodb\lib\cmap\connection.js:65:46)
at Socket.emit (node:events:527:28)
at TCP.<anonymous> (node:net:709:12) {
[Symbol(errorLabels)]: Set(0) {}
}
}
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
logicalSessionTimeoutMinutes: undefined
},
code: undefined,
[Symbol(errorLabels)]: Set(0) {}
}
我已經嘗試將我的 ip 和其他內容列入白名單,但它仍然無法正常工作。 有人可以幫我解決這個問題嗎?
我遇到了相同類型的錯誤 <-- node_modules\mongodb\lib\cmap\connection.js:138:19) --->
我意識到在 mongodb 集群中我選擇了“添加當前 IP 地址”,當我將其編輯為“允許從任何地方訪問”時,我的問題得到了解決。 也許這可以解決您的問題。
按照路徑:Atlas-> 網絡訪問 -> IP 訪問列表 -> 編輯 -> 允許從任何地方訪問
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.