Continuing to get this error

Hello,

I’ve been experiencing this issue with Mongo (currently on a free m0). I’m currently running a node/express/mongoose server on repl.it and occasionally run into this issue. Usually it lasts permanently until I recreate the project again on a new repl.it

This happens when I run the project.

Thing’s i’ve done:

  • add every IP i can think off plus 0.0.0.0
  • uninstall reinstall
  • download the app into my local (i still experience it) and running it.

Strangely: Using tools like ReTool, I can still pull queries from the database even while experiencing this. And the database seems to work fine when I recreate the app from scratch again as a new project. But this only lasts for maybe 5-7 days. Then same issue again.

/home/runner/Cat-1/node_modules/mongoose/lib/connection.js:755
    err = 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://www.mongodb.com/docs/atlas/security-whitelist/
    at _handleConnectionErrors (/home/runner/Cat-1/node_modules/mongoose/lib/connection.js:755:11)
    at NativeConnection.openUri (/home/runner/Cat-1/node_modules/mongoose/lib/connection.js:730:11)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    servers: Map(3) {
      'ac-pmec9fr-shard-00-00.jcedrpx.mongodb.net:27017' => ServerDescription {
        address: 'ac-pmec9fr-shard-00-00.jcedrpx.mongodb.net:27017',
        type: 'Unknown',
        hosts: [],
        passives: [],
        arbiters: [],
        tags: {},
        minWireVersion: 0,
        maxWireVersion: 0,
        roundTripTime: -1,
        lastUpdateTime: 3256436,
        lastWriteDate: 0,
        error: MongoNetworkError: getaddrinfo ENOTFOUND ac-pmec9fr-shard-00-00.jcedrpx.mongodb.net
            at connectionFailureError (/home/runner/Cat-1/node_modules/mongoose/node_modules/mongodb/lib/cmap/connect.js:383:20)
            at TLSSocket.<anonymous> (/home/runner/Cat-1/node_modules/mongoose/node_modules/mongodb/lib/cmap/connect.js:307:22)
            at Object.onceWrapper (node:events:628:26)
            at TLSSocket.emit (node:events:513:28)
            at TLSSocket.emit (node:domain:489:12)
            at emitErrorNT (node:internal/streams/destroy:151:8)
            at emitErrorCloseNT (node:internal/streams/destroy:116:3)
            at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
          cause: Error: getaddrinfo ENOTFOUND ac-pmec9fr-shard-00-00.jcedrpx.mongodb.net
              at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
            errno: -3008,
            code: 'ENOTFOUND',
            syscall: 'getaddrinfo',
            hostname: 'ac-pmec9fr-shard-00-00.jcedrpx.mongodb.net'
          },
          [Symbol(errorLabels)]: Set(1) { 'ResetPool' }
        },
        topologyVersion: null,
        setName: null,
        setVersion: null,
        electionId: null,
        logicalSessionTimeoutMinutes: null,
        primary: null,
        me: null,
        '$clusterTime': null
      },
      'ac-pmec9fr-shard-00-01.jcedrpx.mongodb.net:27017' => ServerDescription {
        address: 'ac-pmec9fr-shard-00-01.jcedrpx.mongodb.net:27017',
        type: 'Unknown',
        hosts: [],
        passives: [],
        arbiters: [],
        tags: {},
        minWireVersion: 0,
        maxWireVersion: 0,
        roundTripTime: -1,
        lastUpdateTime: 3256433,
        lastWriteDate: 0,
        error: MongoNetworkError: getaddrinfo ENOTFOUND ac-pmec9fr-shard-00-01.jcedrpx.mongodb.net
            at connectionFailureError (/home/runner/Cat-1/node_modules/mongoose/node_modules/mongodb/lib/cmap/connect.js:383:20)
            at TLSSocket.<anonymous> (/home/runner/Cat-1/node_modules/mongoose/node_modules/mongodb/lib/cmap/connect.js:307:22)
            at Object.onceWrapper (node:events:628:26)
            at TLSSocket.emit (node:events:513:28)
            at TLSSocket.emit (node:domain:489:12)
            at emitErrorNT (node:internal/streams/destroy:151:8)
            at emitErrorCloseNT (node:internal/streams/destroy:116:3)
            at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
          cause: Error: getaddrinfo ENOTFOUND ac-pmec9fr-shard-00-01.jcedrpx.mongodb.net
              at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
            errno: -3008,
            code: 'ENOTFOUND',
            syscall: 'getaddrinfo',
            hostname: 'ac-pmec9fr-shard-00-01.jcedrpx.mongodb.net'
          },
          [Symbol(errorLabels)]: Set(1) { 'ResetPool' }
        },
        topologyVersion: null,
        setName: null,
        setVersion: null,
        electionId: null,
        logicalSessionTimeoutMinutes: null,
        primary: null,
        me: null,
        '$clusterTime': null
      },
      'ac-pmec9fr-shard-00-02.jcedrpx.mongodb.net:27017' => ServerDescription {
        address: 'ac-pmec9fr-shard-00-02.jcedrpx.mongodb.net:27017',
        type: 'Unknown',
        hosts: [],
        passives: [],
        arbiters: [],
        tags: {},
        minWireVersion: 0,
        maxWireVersion: 0,
        roundTripTime: -1,
        lastUpdateTime: 3255939,
        lastWriteDate: 0,
        error: MongoNetworkError: getaddrinfo ENOTFOUND ac-pmec9fr-shard-00-02.jcedrpx.mongodb.net
            at connectionFailureError (/home/runner/Cat-1/node_modules/mongoose/node_modules/mongodb/lib/cmap/connect.js:383:20)
            at TLSSocket.<anonymous> (/home/runner/Cat-1/node_modules/mongoose/node_modules/mongodb/lib/cmap/connect.js:307:22)
            at Object.onceWrapper (node:events:628:26)
            at TLSSocket.emit (node:events:513:28)
            at TLSSocket.emit (node:domain:489:12)
            at emitErrorNT (node:internal/streams/destroy:151:8)
            at emitErrorCloseNT (node:internal/streams/destroy:116:3)
            at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
          cause: Error: getaddrinfo ENOTFOUND ac-pmec9fr-shard-00-02.jcedrpx.mongodb.net
              at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:107:26) {
            errno: -3008,
            code: 'ENOTFOUND',
            syscall: 'getaddrinfo',
            hostname: 'ac-pmec9fr-shard-00-02.jcedrpx.mongodb.net'
          },
          [Symbol(errorLabels)]: Set(1) { 'ResetPool' }
        },
        topologyVersion: null,
        setName: null,
        setVersion: null,
        electionId: null,
        logicalSessionTimeoutMinutes: null,
        primary: null,
        me: null,
        '$clusterTime': null
      }
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-w46576-shard-0',
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  },
  code: undefined
}

Node.js v18.12.1
exit status 1
 

Hi,
I’d recommend you to change the question title for something that clearly states the problem you’re facing. The current one is far too generic and may not draw enough attention.

My suggestion:

Random “Could not connect to any servers in your MongoDB Atlas cluster” while connecting from white-listed IPs

Hey @Phung_Dao,

Welcome to the MongoDB Community forums :sparkles:

It appears that other members of the community had encountered the same issue before, and it was determined that the problem does not lie with MongoDB, but with repl.it. Would you kindly consider sending a bug report to the repl.it team to bring their attention to the issue? Additionally, for further details, please refer to the thread I have linked below.

Best,
Kushagra