MongoServerSelectionError: connection closed

Hi,
When I try to submit a form in a localhost:5000 website, I am getting a

MongoServerSelectionError: connection <monitor> closed
    at Timeout._onTimeout (/Users/_/Desktop/Clone/node_modules/mongodb/lib/sdam/topology.js:318:38)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7) {
  reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    servers: Map(3) {
      'cluster0-shard-00-00.d1mrz.mongodb.net:27017' => [ServerDescription],
      'cluster0-shard-00-01.d1mrz.mongodb.net:27017' => [ServerDescription],
      'cluster0-shard-00-02.d1mrz.mongodb.net:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: 'atlas-lkpac7-shard-0',
    logicalSessionTimeoutMinutes: undefined
  },
  code: undefined,
  [Symbol(errorLabels)]: Set(0) {}
}

error. I’m unsure why this is happening. I don’t know if it’s because for some reason it’s listing 3 in servers: Map(3) {...}, but I would really appreciate any advice on how to fix this.

Have you whitelisted your IP?

1 Like

Thank you! That worked. I had seen something that mentioned whitelisting an IP for a similar issue, but I was not sure where in mongodb that was, so that article was perfect!

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.