Hi @Bhuvanesh_R ,
As @steevej mentioned, with a replica set connection clients use the hostnames listed in the replica set configuration per the Server Discovery and Monitoring (SDAM) specification implemented by official MongoDB drivers.
The rationale for this behaviour is to support failover and zero-downtime reconfiguration, which are key features of a replica set connection. Establishing a connection to a single replica set member (aka a “direct connection”) does not include failover or discovery of the replica set configuration, so will work if you are port forwarding via a different inbound hostname/IP/port combination.
If you want to establish a remote connection to a replica set hosted on a private network and take advantage of failover and automatic reconfiguration, the most straightforward approach would be to have your clients connect using via the VPC or a VPN.
Regards,
Stennie