MongoDB Atlas‘ETIMEDOUT’错误

MongoDB Atlas‘ETIMEDOUT’错误

MongoDB Atlas 曾经运行良好。现在我有一段时间无法连接。我在这个论坛和其他论坛上查看了其他解决方案。

使用应用程序连接字符串、MongoDB Compass 应用程序连接字符串以及 MongoDB shell 连接字符串时,我遇到了上述错误。以下是我尝试过的方法:

我尝试使用不同的云提供商和区域/区域创建一个新的 MongoDB Atlas 帐户。MongoDB Atlas 在 Windows Defender 的出站规则中有一个连接规则。(远程端口 27015-27017)。我猜这是 MongoDB 在安装期间创建的,因此防火墙不应该是问题。白名单 0.0.0.0/0(存在安全风险,但这里没有有价值的数据)。开始使用不需要 url 编码的密码(没有特殊字符)。这是我的软件列表:nodejs:v16.13.0 express:v4.18.1 mongoose:v6.5.2

我确实读过一些关于降低节点版本以修复此问题的文章。如果是这样的话,我愿意这么做,但是应该将其降低到多少呢?

MongoDB Compass 连接字符串:mongodb+srv://brohjoe1:[电子邮件保护]/授权

错误信息如下:

App is listening at http://localhost:3001
C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongoose\lib\connection.js:824
  const serverSelectionError = new ServerSelectionError();
                               ^

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\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongoose\lib\connection.js:824:32)
    at C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongoose\lib\index.js:380:10
    at C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongoose\lib\helpers\promiseOrCallback.js:41:5
    at new Promise (<anonymous>)
    at promiseOrCallback (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongoose\lib\helpers\promiseOrCallback.js:40:10)
    at Mongoose._promiseOrCallback (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongoose\lib\index.js:1225:10)
    at Mongoose.connect (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongoose\lib\index.js:379:20)
    at Object.<anonymous> (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\app.js:11:10)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    servers: Map(3) {
      'ac-v2tectr-shard-00-01.4ross7o.mongodb.net:27017' => ServerDescription {
        _hostAddress: HostAddress {
          isIPv6: false,
          host: 'ac-v2tectr-shard-00-01.4ross7o.mongodb.net',
          port: 27017
        },
        address: 'ac-v2tectr-shard-00-01.4ross7o.mongodb.net:27017',
        type: 'Unknown',
        hosts: [],
        passives: [],
        arbiters: [],
        tags: {},
        minWireVersion: 0,
        maxWireVersion: 0,
        roundTripTime: -1,
        lastUpdateTime: 1097611983,
        lastWriteDate: 0,
        error: MongoNetworkError: connect ETIMEDOUT 35.239.246.213:27017
            at connectionFailureError (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongodb\lib\cmap\connect.js:379:20)
            at TLSSocket.<anonymous> (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongodb\lib\cmap\connect.js:302:22)
            at Object.onceWrapper (node:events:510:26)
            at TLSSocket.emit (node:events:390:28)
            at emitErrorNT (node:internal/streams/destroy:157:8)
            at emitErrorCloseNT (node:internal/streams/destroy:122:3)
            at processTicksAndRejections (node:internal/process/task_queues:83:21) {
          [Symbol(errorLabels)]: Set(0) {}
        }
      },
      'ac-v2tectr-shard-00-02.4ross7o.mongodb.net:27017' => ServerDescription {
        _hostAddress: HostAddress {
          isIPv6: false,
          host: 'ac-v2tectr-shard-00-02.4ross7o.mongodb.net',
          port: 27017
        },
        address: 'ac-v2tectr-shard-00-02.4ross7o.mongodb.net:27017',
        type: 'Unknown',
        hosts: [],
        passives: [],
        arbiters: [],
        tags: {},
        minWireVersion: 0,
        maxWireVersion: 0,
        roundTripTime: -1,
        lastUpdateTime: 1097611977,
        lastWriteDate: 0,
        error: MongoNetworkError: connect ETIMEDOUT 35.232.109.33:27017
            at connectionFailureError (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongodb\lib\cmap\connect.js:379:20)
            at TLSSocket.<anonymous> (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongodb\lib\cmap\connect.js:302:22)
            at Object.onceWrapper (node:events:510:26)
            at TLSSocket.emit (node:events:390:28)
            at emitErrorNT (node:internal/streams/destroy:157:8)
            at emitErrorCloseNT (node:internal/streams/destroy:122:3)
            at processTicksAndRejections (node:internal/process/task_queues:83:21) {
          [Symbol(errorLabels)]: Set(0) {}
        }
      },
      'ac-v2tectr-shard-00-00.4ross7o.mongodb.net:27017' => ServerDescription {
        _hostAddress: HostAddress {
          isIPv6: false,
          host: 'ac-v2tectr-shard-00-00.4ross7o.mongodb.net',
          port: 27017
        },
        address: 'ac-v2tectr-shard-00-00.4ross7o.mongodb.net:27017',
        type: 'Unknown',
        hosts: [],
        passives: [],
        arbiters: [],
        tags: {},
        minWireVersion: 0,
        maxWireVersion: 0,
        roundTripTime: -1,
        lastUpdateTime: 1097612045,
        lastWriteDate: 0,
        error: MongoNetworkError: connect ETIMEDOUT 35.238.72.187:27017
            at connectionFailureError (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongodb\lib\cmap\connect.js:379:20)
            at TLSSocket.<anonymous> (C:\Users\brohj\WebstormProjects\Firebase\redEyeMedia\node_modules\mongodb\lib\cmap\connect.js:302:22)
            at Object.onceWrapper (node:events:510:26)
            at TLSSocket.emit (node:events:390:28)
            at emitErrorNT (node:internal/streams/destroy:157:8)
            at emitErrorCloseNT (node:internal/streams/destroy:122:3)
            at processTicksAndRejections (node:internal/process/task_queues:83:21) {
          [Symbol(errorLabels)]: Set(0) {}
        }
      }
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-bt7sor-shard-0',
    logicalSessionTimeoutMinutes: undefined
  },
  code: undefined
}

答案1

我的问题是出在我的互联网服务提供商身上。我联系了他们,并向他们解释说我认为有些端口被封锁了,他们打开了端口,之后我就没遇到任何问题了。我记不清具体细节了,因为那是 7 个月前的事了,但当时是 ISP 的防火墙封锁了我。我希望这对其他人有所帮助。我刚刚注意到这个帖子的浏览量已经超过 1000 人,我已经忘记了这篇文章,而且由于它没有答案,所以我来回答一下。

相关内容