D
D
dufrein20132021-03-27 16:26:52
MongoDB
dufrein2013, 2021-03-27 16:26:52

Why does a MongooseServerSelectionError occur when connecting to a local mongodb database?

Error when connecting to local mongodb database mongodb://localhost:27017/?replicaSet=rs0/ users

Mongoose default connection has occured 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/ error

Готов задонатить за ответ если поможет)
Although I don’t use any cluster, before everything was on another PC and worked, it was necessary to recreate everything on a new hard drive, installed mongo, node, mongodb driver, created a replica and this error comes out, there is also such a footcloth in the error info
reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map(0) {},
    stale: false,
    compatible: true,
    compatibilityError: null,
    logicalSessionTimeoutMinutes: null,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    commonWireVersion: 9
  }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
dufrein2013, 2021-03-28
@dufrein2013

everything turned out to be simple, it was necessary to add the name of the replica to the mongi config file:

replication:
   replSetName: <string>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question