I have started learning MongoDB, I am just trying to connect to the database using MongoDB Shell. I am using the below command.
mongosh "mongodb+srv://cluster0.12345.mongodb.net/myFirstDatabase" --username viveknuna
I have added my current IP Address to IP Access List. But getting this error.
MongoServerSelectionError: connection to closed
I have referred to this question and added 0.0.0.0/0 (Allow access from AnyWhere) in the IP Access List. and it works as expected. But this is a security risk, Is there any way without allowing all IPs.
FYI: I am inside Virtual Machine and running this command also from VM.