Error while connect to cluster from Mongo shell

I am giving this command as per lecture notes:
mongo “mongodb://cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/test?replicaSet=Cluster0-shard-0” --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

but getting this error:
2019-08-09T15:01:41.633-0400 E QUERY [js] SyntaxError: missing ; before statement @(shell):1:clock6:
Can you please help?

Hi @BIMAL_THAKKAR_89565,

This error means you are already inside the mongo shell. First you need to exit out of the mongo shell by using the quit() command.

quit()

Now you can use your connection string to connect to the cluster.

If you still have any issue, feel free to get back to us. Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Thanks.

I was able to connect, but soon I m getting this error:

2019-08-09T16:34:42.541-0400 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0

*** It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.

2019-08-09T16:34:42.548-0400 E QUERY [js] Error: connect failed to replica set Cluster0-shard-0/cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017 :
connect@src/mongo/shell/mongo.js:344:17
@(connect):2:6
exception: connect failed

Hi @BIMAL_THAKKAR_89565,

Please make sure you are not behind a firewall or using a VPN connection. Follow the steps mentioned below to check if you are able to reach the cluster and your port (27017) is not blocked.

Please share the screenshot of the responses or any error that you get.

Thanks,
Shubham Ranjan
Curriculum Support Engineer