I am trying to connect to my atlas cluster using connect()
method and getting error as "No Primary Detected"
.
Here are the steps i performed:
- Run the mongo shell from command prompt.
- Execute load(); by passing the script file name.
File contains below script:
var url = "mongodb://leeban-m001-shard-00-00-sqjjv.mongodb.net:27017,leeban-m001-shard-00-01-sqjjv.mongodb.net:27017,leeban-m001-shard-00-02-sqjjv.mongodb.net:27017/test?replicaSet=Leeban-M001-shard-0";
var userName="mongo-m001";
var password="******";
var database = connect(url, userName, password);
When I execute the command through shell (without using connect method.) I am able to connect to Atlas cluster.
Is connect()
method will work to connect to mongodb clusters?