Could not find host matching read preference { mode: “primary” } for set

**Could not find host matching read preference { mode: “primary” } for set **

I used sh.status() in mongos.
I checked the following error in the balancer

what is the error
Please tell me how to fix the error

Could you please give some more information about your sharded cluster setup. IE number of shards, and number of servers in each shard replica set?

Most of the time when I see this error it is when a shard replica set doesn’t have a primary node so the mongos/configs can’t find the primary node. This causes issues because it can’t route writes to the primary of the shard.

I would check all of the shard servers directly to verify they are in a healthy state and each shard has a primary node.

1 Like