Mongodb replicaset secondaries showing not reachable/healthy. It was working fine once the machine restarted it shows both secondary as reachable/healthy. I configured first secondary in the port 27027 and second secondary in 27037. When i Checked rs.status() i got below result.
rs0:PRIMARY> rs.status()
{
"set" : "rs0",
"date" : ISODate("2021-03-23T05:52:50.311Z"),
"myState" : 1,
"term" : NumberLong(5),
"syncSourceHost" : "",
"syncSourceId" : -1,
"heartbeatIntervalMillis" : NumberLong(2000),
"majorityVoteCount" : 1,
"writeMajorityCount" : 1,
"votingMembersCount" : 1,
"writableVotingMembersCount" : 1,
"optimes" : {
"lastCommittedOpTime" : {
"ts" : Timestamp(1616478761, 1),
"t" : NumberLong(5)
},
"lastCommittedWallTime" : ISODate("2021-03-23T05:52:41.265Z"),
"readConcernMajorityOpTime" : {
"ts" : Timestamp(1616478761, 1),
"t" : NumberLong(5)
},
"readConcernMajorityWallTime" : ISODate("2021-03-23T05:52:41.265Z"),
"appliedOpTime" : {
"ts" : Timestamp(1616478761, 1),
"t" : NumberLong(5)
},
"durableOpTime" : {
"ts" : Timestamp(1616478761, 1),
"t" : NumberLong(5)
},
"lastAppliedWallTime" : ISODate("2021-03-23T05:52:41.265Z"),
"lastDurableWallTime" : ISODate("2021-03-23T05:52:41.265Z")
},
"lastStableRecoveryTimestamp" : Timestamp(1616478711, 1),
"electionCandidateMetrics" : {
"lastElectionReason" : "electionTimeout",
"lastElectionDate" : ISODate("2021-03-23T05:44:09.131Z"),
"electionTerm" : NumberLong(5),
"lastCommittedOpTimeAtElection" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"lastSeenOpTimeAtElection" : {
"ts" : Timestamp(1616478202, 1),
"t" : NumberLong(4)
},
"numVotesNeeded" : 1,
"priorityAtElection" : 1,
"electionTimeoutMillis" : NumberLong(10000),
"numCatchUpOps" : NumberLong(0),
"newTermStartDate" : ISODate("2021-03-23T05:44:11.152Z"),
"wMajorityWriteAvailabilityDate" : ISODate("2021-03-23T05:44:11.238Z")
},
"members" : [
{
"_id" : 0,
"name" : "127.0.0.1:27017",
"health" : 1,
"state" : 1,
"stateStr" : "PRIMARY",
"uptime" : 540,
"optime" : {
"ts" : Timestamp(1616478761, 1),
"t" : NumberLong(5)
},
"optimeDate" : ISODate("2021-03-23T05:52:41Z"),
"syncSourceHost" : "",
"syncSourceId" : -1,
"infoMessage" : "",
"electionTime" : Timestamp(1616478249, 1),
"electionDate" : ISODate("2021-03-23T05:44:09Z"),
"configVersion" : 3,
"configTerm" : 5,
"self" : true,
"lastHeartbeatMessage" : ""
},
{
"_id" : 1,
"name" : "127.0.0.1:27027",
"health" : 0,
"state" : 8,
"stateStr" : "(not reachable/healthy)",
"uptime" : 0,
"optime" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"optimeDurable" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"optimeDurableDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2021-03-23T05:52:47.779Z"),
"lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
"pingMs" : NumberLong(0),
"lastHeartbeatMessage" : "Error connecting to 127.0.0.1:27027 :: caused by :: No connection could be made because the target machine actively refused it.",
"syncSourceHost" : "",
"syncSourceId" : -1,
"infoMessage" : "",
"configVersion" : -1,
"configTerm" : -1
},
{
"_id" : 2,
"name" : "127.0.0.1:27037",
"health" : 0,
"state" : 8,
"stateStr" : "(not reachable/healthy)",
"uptime" : 0,
"optime" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"optimeDurable" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"optimeDurableDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2021-03-23T05:52:47.768Z"),
"lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
"pingMs" : NumberLong(0),
"lastHeartbeatMessage" : "Error connecting to 127.0.0.1:27037 :: caused by :: No connection could be made because the target machine actively refused it.",
"syncSourceHost" : "",
"syncSourceId" : -1,
"infoMessage" : "",
"configVersion" : -1,
"configTerm" : -1
}
],
"ok" : 1,
"$clusterTime" : {
"clusterTime" : Timestamp(1616478761, 1),
"signature" : {
"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
"keyId" : NumberLong(0)
}
},
"operationTime" : Timestamp(1616478761, 1)
}