I am getting the error while adding shard as below:
Command
sh.addShard("test-shardsrv-replica/shard1:27018");
Error
MongoServerError: Could not find host matching read preference { mode: "primary" } for set test-shardsrv-replica
My Shard Replica Set Status
{
set: 'test-shardsrv-replica',
date: ISODate("2023-06-29T13:42:41.974Z"),
myState: 1,
term: Long("4"),
syncSourceHost: '',
syncSourceId: -1,
heartbeatIntervalMillis: Long("2000"),
majorityVoteCount: 1,
writeMajorityCount: 1,
votingMembersCount: 1,
writableVotingMembersCount: 1,
optimes: {
lastCommittedOpTime: { ts: Timestamp({ t: 1688046154, i: 1 }), t: Long("4") },
lastCommittedWallTime: ISODate("2023-06-29T13:42:34.937Z"),
readConcernMajorityOpTime: { ts: Timestamp({ t: 1688046154, i: 1 }), t: Long("4") },
appliedOpTime: { ts: Timestamp({ t: 1688046154, i: 1 }), t: Long("4") },
durableOpTime: { ts: Timestamp({ t: 1688046154, i: 1 }), t: Long("4") },
lastAppliedWallTime: ISODate("2023-06-29T13:42:34.937Z"),
lastDurableWallTime: ISODate("2023-06-29T13:42:34.937Z")
},
lastStableRecoveryTimestamp: Timestamp({ t: 1688046144, i: 1 }),
electionCandidateMetrics: {
lastElectionReason: 'electionTimeout',
lastElectionDate: ISODate("2023-06-28T07:46:23.215Z"),
electionTerm: Long("4"),
lastCommittedOpTimeAtElection: { ts: Timestamp({ t: 0, i: 0 }), t: Long("-1") },
lastSeenOpTimeAtElection: { ts: Timestamp({ t: 1687938379, i: 1 }), t: Long("3") },
numVotesNeeded: 1,
priorityAtElection: 1,
electionTimeoutMillis: Long("10000"),
newTermStartDate: ISODate("2023-06-28T07:46:23.216Z"),
wMajorityWriteAvailabilityDate: ISODate("2023-06-28T07:46:23.217Z")
},
members: [
{
_id: 0,
name: 'shard1:27018',
health: 1,
state: 1,
stateStr: 'PRIMARY',
uptime: 107779,
optime: { ts: Timestamp({ t: 1688046154, i: 1 }), t: Long("4") },
optimeDate: ISODate("2023-06-29T13:42:34.000Z"),
lastAppliedWallTime: ISODate("2023-06-29T13:42:34.937Z"),
lastDurableWallTime: ISODate("2023-06-29T13:42:34.937Z"),
syncSourceHost: '',
syncSourceId: -1,
infoMessage: '',
electionTime: Timestamp({ t: 1687938383, i: 1 }),
electionDate: ISODate("2023-06-28T07:46:23.000Z"),
configVersion: 59857,
configTerm: -1,
self: true,
lastHeartbeatMessage: ''
}
],
ok: 1,
'$clusterTime': {
clusterTime: Timestamp({ t: 1688046154, i: 1 }),
signature: {
hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
keyId: Long("0")
}
},
operationTime: Timestamp({ t: 1688046154, i: 1 })
}
Any Help would be Appreciated, Thanks!