"Could not find host matching read preference { mode: \"primary\" }

Getting error while Adding new shard to cluster from mongos:

I am working on -Video example - Setting Up a Sharded Cluster-Chapter 3: Sharding

Ran the following command
Adding new shard to cluster from mongos:

MongoDB Enterprise mongos> sh.addShard(“m103-repl-RAO/”)

below is the error message

“ok” : 0,
“errmsg” : “Could not find host matching read preference { mode: “primary” } for set m103-repl-RAO”,
“code” : 133,
“codeName” : “FailedToSatisfyReadPreference”,

My replica set validation

MongoDB Enterprise m103-repl-RAO:PRIMARY> rs.isMaster()
“hosts” : [
“setName” : “m103-repl-RAO”,
“setVersion” : 3,
“ismaster” : true,
“secondary” : false,
“primary” : “”,

Validating sharding status:

MongoDB Enterprise mongos> sh.status()
— Sharding Status —
sharding version: {
“_id” : 1,
“minCompatibleVersion” : 5,
“currentVersion” : 6,
“clusterId” : ObjectId(“5e63ddfb0b745846c1adc524”)
active mongoses:
“3.6.17” : 1
Currently enabled: yes
Currently enabled: yes
Currently running: no
Failed balancer rounds in last 5 attempts: 0
Migration Results for the last 24 hours:
No recent migrations
{ “_id” : “config”, “primary” : “config”, “partitioned” : true }

  1. Check the rs.status() for this replica set to ensure that all nodes are healthy
  2. Don’t use mixed hostnames like you have above
  3. Enter a comma separated list of all nodes in the sh.add() command

Hi @Subba_17461,

In addition to @007_jb,

Please run this command in your vagrant machine and share the output :

ping m103

Thanks, I think I messed up with the config files, i am going to clear the db folder and create the replication from the scratch.