Cannot do a mongodump


I have this porblem on a ReplicaSet. I cannot do a mongodump.

I have this message :
Failed: can’t create session: could not connect to server: server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [] }

How can i fix this ?

Is your DB up and running?

Are you taking dump from a local DB or remotely
Give us more details

Yes sorry.

I’m taking a dump localy and the DB is up i can connect to the ReplicaSet and check database and so on.
The database worked during 5months and then this message.

I’ve two replicaset on one server (two replicaset with one node), I know it’s not a best pratice but i had no choice about that.

It says no primary
Do you see any errors in your logs
Any other associated errors?
What is your mongodump version
Can you share the command?Does it use host or uri or none as you mentioned it is on local DB

Yes but there is one i can see the primary when i’m connected to replicaset and do an rs.status().
In logs i don’t see any errors only the connections on the database and the disconnection.

I used the 4.2 mongodump version and i did it with uri command like that :

mongodump --uri=“mongodb://admin:mypassword@myIPhost/?replicaSet=myreplicasetname” --out “directory”

Please check if your syntax is correct or not
Standard string will be like


Also try SRV string

mongodump --uri “mongodb+srv://” --out “C:\Dump”

You can get commands for your cluster from Atlas

The standard string change pretty fast because 6months ago it was not that on MongoDB.

Because with strings i cannot do a backup of all my ReplicaSet. How can i save all the ReplicaSet ?

I cannot do this from Atlas because i’m not on a cloud infrastructure.

Have you tried with --uri and --host given under connect to replicaset in this doc?

I’m doing this command :

mongodump --uri=“mongodb://,,

But i just add connection with a user it should works no ?

This is a example string
Replace with your cluster
Yes you can add username:pwd