When you connect to a replicaset the first node reached will seed the replicaset connection by retreiving data from the replicaset. Usually this is hostnames. Those hostnames need to be resolvable by each node any client that is accessing the replica set.
For a one off you can create entries in your clients hosts files as a workaround. Or ssh tunnel.
If it is a deployment that will be connectible externally then you may need to update what names you are using in the replicaset configuration.
Finally, it is strongly recommended to not expose any database server to the public internet without a thorough security checks and precautions, or if you don’t really need to (e.g. IP whitelisting and enabling auth are practically the bare minimum requirement). This is true for any database servers, not only MongoDB. Please see the Security Checklist.
But if we want to access database securely from GUI application (from specific system) then how can we do that without exposing database IP to public?
You may be able to use IP whitelisting to restrict access to the server to certain IP addresses. Having said that, note that although whitelisting is one solution, it’s also best to secure the server using all the security options available in MongoDB as well (see the security checklist).