MongooseServerSelectionError:无法连接到 MongoDB Atlas 集群中的任何服务器

时间:2021-02-28 12:42:32

标签: node.js mongodb windows-firewall

MongooseServerSelectionError:无法连接到您的 MongoDB Atlas 集群中的任何服务器。一个常见原因是您尝试从未列入白名单的 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/
        at NativeConnection.Connection.openUri (C:\Users\Admin\Desktop\Working\SB\node_modules\mongoose\lib\connection.js:832:32)
        at C:\Users\Admin\Desktop\Working\SB\node_modules\mongoose\lib\index.js:345:10
        at C:\Users\Admin\Desktop\Working\SB\node_modules\mongoose\lib\helpers\promiseOrCallback.js:31:5
        at new Promise (<anonymous>)
        at promiseOrCallback (C:\Users\Admin\Desktop\Working\SB\node_modules\mongoose\lib\helpers\promiseOrCallback.js:30:10)
        at Mongoose._promiseOrCallback (C:\Users\Admin\Desktop\Working\SB\node_modules\mongoose\lib\index.js:1135:10)
        at Mongoose.connect (C:\Users\Admin\Desktop\Working\SB\node_modules\mongoose\lib\index.js:344:20)
        at Object.<anonymous> (C:\Users\Admin\Desktop\Working\SB\app.js:305:10)    at Module._compile (internal/modules/cjs/loader.js:1138:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
        at Module.load (internal/modules/cjs/loader.js:986:32)
        at Function.Module._load (internal/modules/cjs/loader.js:879:14)       
        at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
        at internal/main/run_main_module.js:17:47 {
      reason: TopologyDescription {
        type: 'ReplicaSetNoPrimary',
        setName: null,
        maxSetVersion: null,
        maxElectionId: null,
        servers: Map {
          'smile-shard-00-00.xeyqd.mongodb.net:27017' => [ServerDescription],  
          'smile-shard-00-01.xeyqd.mongodb.net:27017' => [ServerDescription],  
          'smile-shard-00-02.xeyqd.mongodb.net:27017' => [ServerDescription]   
        },
        stale: false,
        compatible: true,
        compatibilityError: null,
        logicalSessionTimeoutMinutes: null,
        heartbeatFrequencyMS: 10000,
        localThresholdMS: 15,
        commonWireVersion: null
      }
    }

我已经将 IP 地址更新为 mongodb 网络访问 => IP 访问列表为 0.0.0.0/0 但是错误还是发生了。我认为这个错误是由于窗口防火墙造成的。但我不知道如何解决这个问题。

0 个答案:

没有答案
相关问题