首页 > 解决方案 > 将我的 IP 地址列入白名单后,将 mongodb 与 mongoose 连接时出现问题

问题描述

我无法连接到我的 MongoDb 数据库。我检查了几次,我的 IP 地址在网络访问中正确列入白名单。我有以下信息:

  message:
   '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/',
  reason:
   TopologyDescription {
     type: 'ReplicaSetNoPrimary',
     setName: null,
     maxSetVersion: null,
     maxElectionId: null,
     servers:
      Map {
        'cluster0-shard-00-01-216w6.mongodb.net:27017' => [ServerDescription],
        'cluster0-shard-00-02-216w6.mongodb.net:27017' => [ServerDescription],
        'cluster0-shard-00-00-216w6.mongodb.net:27017' => [ServerDescription] },
     stale: false,
     compatible: true,
     compatibilityError: null,
     logicalSessionTimeoutMinutes: null,
     heartbeatFrequencyMS: 10000,
     localThresholdMS: 15,
     commonWireVersion: null } }
^C

标签: node.jswindowsmongodbmongooseconnection

解决方案


我遇到了同样的问题并通过以下方式解决了它:

  1. 转到“网络访问”。

  2. 在注册的 IP 地址上,转到“编辑”操作。

  3. 如果您的 IP 地址已更改,您将看到允许访问当前 IP 地址的选项,单击该选项以更新 IP。


推荐阅读