I have a replicaSet which consists of three databases running locally on an Ubuntu virtual machine with the following configuration

As seen above, I have three databases hosted on ports 27018, 27019, and 27020. All having the same host name. They are all up and running and below is the output of rs.status()
{
set: 'Dist',
date: ISODate("2022-06-24T01:07:36.657Z"),
myState: 1,
term: Long("24"),
syncSourceHost: '',
syncSourceId: -1,
heartbeatIntervalMillis: Long("2000"),
majorityVoteCount: 2,
writeMajorityCount: 2,
votingMembersCount: 3,
writableVotingMembersCount: 3,
optimes: {
lastCommittedOpTime: { ts: Timestamp({ t: 1656032848, i: 1 }), t: Long("24") },
lastCommittedWallTime: ISODate("2022-06-24T01:07:28.662Z"),
readConcernMajorityOpTime: { ts: Timestamp({ t: 1656032848, i: 1 }), t: Long("24") },
appliedOpTime: { ts: Timestamp({ t: 1656032848, i: 1 }), t: Long("24") },
durableOpTime: { ts: Timestamp({ t: 1656032848, i: 1 }), t: Long("24") },
lastAppliedWallTime: ISODate("2022-06-24T01:07:28.662Z"),
lastDurableWallTime: ISODate("2022-06-24T01:07:28.662Z")
},
lastStableRecoveryTimestamp: Timestamp({ t: 1656032848, i: 1 }),
electionCandidateMetrics: {
lastElectionReason: 'electionTimeout',
lastElectionDate: ISODate("2022-06-23T23:45:44.849Z"),
electionTerm: Long("24"),
lastCommittedOpTimeAtElection: { ts: Timestamp({ t: 0, i: 0 }), t: Long("-1") },
lastSeenOpTimeAtElection: { ts: Timestamp({ t: 1656027744, i: 1 }), t: Long("21") },
numVotesNeeded: 2,
priorityAtElection: 1,
electionTimeoutMillis: Long("10000"),
numCatchUpOps: Long("0"),
newTermStartDate: ISODate("2022-06-23T23:45:44.968Z"),
wMajorityWriteAvailabilityDate: ISODate("2022-06-23T23:45:47.178Z")
},
electionParticipantMetrics: {
votedForCandidate: false,
electionTerm: Long("23"),
lastVoteDate: ISODate("2022-06-23T23:45:36.502Z"),
electionCandidateMemberId: 2,
voteReason: 'already voted for another candidate (localhost:27018) this term (23)',
lastAppliedOpTimeAtElection: { ts: Timestamp({ t: 1656027744, i: 1 }), t: Long("21") },
maxAppliedOpTimeInSet: { ts: Timestamp({ t: 1656027744, i: 1 }), t: Long("21") },
priorityAtElection: 1
},
members: [
{
_id: 0,
name: 'localhost:27018',
health: 1,
state: 1,
stateStr: 'PRIMARY',
uptime: 5067,
optime: { ts: Timestamp({ t: 1656032848, i: 1 }), t: Long("24") },
optimeDate: ISODate("2022-06-24T01:07:28.000Z"),
lastAppliedWallTime: ISODate("2022-06-24T01:07:28.662Z"),
lastDurableWallTime: ISODate("2022-06-24T01:07:28.662Z"),
syncSourceHost: '',
syncSourceId: -1,
infoMessage: '',
electionTime: Timestamp({ t: 1656027944, i: 1 }),
electionDate: ISODate("2022-06-23T23:45:44.000Z"),
configVersion: 1,
configTerm: 24,
self: true,
lastHeartbeatMessage: ''
},
{
_id: 1,
name: 'localhost:27019',
health: 1,
state: 2,
stateStr: 'SECONDARY',
uptime: 4933,
optime: { ts: Timestamp({ t: 1656032848, i: 1 }), t: Long("24") },
optimeDurable: { ts: Timestamp({ t: 1656032848, i: 1 }), t: Long("24") },
optimeDate: ISODate("2022-06-24T01:07:28.000Z"),
optimeDurableDate: ISODate("2022-06-24T01:07:28.000Z"),
lastAppliedWallTime: ISODate("2022-06-24T01:07:28.662Z"),
lastDurableWallTime: ISODate("2022-06-24T01:07:28.662Z"),
lastHeartbeat: ISODate("2022-06-24T01:07:36.097Z"),
lastHeartbeatRecv: ISODate("2022-06-24T01:07:35.253Z"),
pingMs: Long("0"),
lastHeartbeatMessage: '',
syncSourceHost: 'localhost:27018',
syncSourceId: 0,
infoMessage: '',
configVersion: 1,
configTerm: 24
},
{
_id: 2,
name: 'localhost:27020',
health: 1,
state: 2,
stateStr: 'SECONDARY',
uptime: 4933,
optime: { ts: Timestamp({ t: 1656032848, i: 1 }), t: Long("24") },
optimeDurable: { ts: Timestamp({ t: 1656032848, i: 1 }), t: Long("24") },
optimeDate: ISODate("2022-06-24T01:07:28.000Z"),
optimeDurableDate: ISODate("2022-06-24T01:07:28.000Z"),
lastAppliedWallTime: ISODate("2022-06-24T01:07:28.662Z"),
lastDurableWallTime: ISODate("2022-06-24T01:07:28.662Z"),
lastHeartbeat: ISODate("2022-06-24T01:07:35.263Z"),
lastHeartbeatRecv: ISODate("2022-06-24T01:07:35.263Z"),
pingMs: Long("178"),
lastHeartbeatMessage: '',
syncSourceHost: 'localhost:27018',
syncSourceId: 0,
infoMessage: '',
configVersion: 1,
configTerm: 24
}
],
ok: 1,
'$clusterTime': {
clusterTime: Timestamp({ t: 1656032848, i: 1 }),
signature: {
hash: Binary(Buffer.from("0000000000000000000000000000000000000000", "hex"), 0),
keyId: Long("0")
}
},
operationTime: Timestamp({ t: 1656032848, i: 1 })
}
Now I have to deploy this replica set in order to connect to it on a mongoose instance in express.js. I tried to workaround and tcp tunnel the three ports using ngrok with the following ngrok.yml configuration
version: "2"
authtoken: <my token here>
tunnels:
db1:
proto: tcp
addr: 27018
db2:
proto: tcp
addr: 27019
db3:
proto: tcp
addr: 27020
and ran the following command ngrok start all, below is the ngrok terminal output
Yet, when I tried to test the connection through MongoDB Compass on my Windows using the following URI, it gave me this error
mongodb://2.tcp.eu.ngrok.io:17012,0.tcp.eu.ngrok.io:16864,7.tcp.eu.ngrok.io:13873/dist1?replicaSet=Dist
I don't really get what can go wrong here. I am not able to subscribe to ngrok at the mean time to have several TCP sessions. so is there any other workaround in order to deploy my own replicaSet and have full control on it (running and shutting down nodes)?
P.S: It is made for a college project.
Thanks in advance!

