I've inherited node.js, mongodb system.
The original dev used a mlab db on his own account, I was asked to copy to a different db.
When I tried to create a mlab user I was redirected to cloud.mongodb.com (which apparently purchase mlab)
I was struggling to create a DB and connect to it through robo 3t
and Compass
, and now I'm able to connect and query the DB.
I used Compass export/import collection to copy the DB (was not able to copy in any other way)
Now I set the db uri in my app to the new db but it hangs when I do findOne
here is the old uri:
mongodb://dekel:password@ds115094.mlab.com:15094/somebuddy
therefore I assumed the connection string should be:
mongodb://root:password@cluster0-shard-00-00-jjbdh.mongodb.net:27017/somebuddy
I get
UnhandledPromiseRejectionWarning: MongoNetworkError: connection 0 to cluster0-shard-00-00-jjbdh.mongodb.net:27017 closed
when I connect with robo 3t
I have to set the Database to admin
other wise I get: Network is unreachable.
therefore I tried the following
mongodb://root:password@cluster0-shard-00-00-jjbdh.mongodb.net:27017/admin
I get:
MongoNetworkError: connection 0 to cluster0-shard-00-00-jjbdh.mongodb.net:27017 closed
The Mongodb site says that the connection string should be
mongodb+srv://root:<password>@cluster0-shard-00-00-jjbdh.mongodb.net/test?retryWrites=true
This is very strange since cluster0-shard-00-00-jjbdh.mongodb.net
doesn't work on robo 3t
and Compass
, so I guess it is only an example.
I tired the following
mongodb+srv://root:password@cluster0-shard-00-00-jjbdh.mongodb.net:27017/somebuddy
I get:
Error: querySrv ENOTFOUND _mongodb._tcp.cluster0-shard-00-00-jjbdh.mongodb.net
I tried with the following different users
when I tried to use the chat on the mongodb website I get:
The team will get back to you on this. MongoDB Cloud Chat will be back tomorrow.
this is what I get when i try to connect with the shell (see https://www.youtube.com/watch?v=Ej05tq1220A):
C:\Program Files\MongoDB\Server\4.0\bin> .\mongo.exe "mongodb+srv://cluster0-jjbdh.mongodb.net/test" --username root
MongoDB shell version v4.0.8
Enter password:
connecting to: mongodb://cluster0-shard-00-01-jjbdh.mongodb.net.:27017,cluster0-shard-00-02-jjbdh.mongodb.net.:27017,cluster0-shard-00-00-jjbdh.mongodb.net.:27017/test?authSource=admin&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0&ssl=true
2019-04-07T19:03:46.945+0300 I NETWORK [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-01-jjbdh.mongodb.net.:27017,cluster0-shard-00-02-jjbdh.mongodb.net.:27017,cluster0-shard-00-00-jjbdh.mongodb.net.:27017
2019-04-07T19:03:58.840+0300 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-04-07T19:03:58.841+0300 I NETWORK [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2019-04-07T19:04:00.281+0300 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-04-07T19:04:00.282+0300 I NETWORK [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 2 checks in a row.
2019-04-07T19:04:01.751+0300 W NETWORK [js] Unable to reach primary for set Cluster0-shard-0
2019-04-07T19:04:01.752+0300 I NETWORK [js] Cannot reach any nodes for set Cluster0-shard-0. Please check network connectivity and the status of the set. This has happened for 3 checks in a row.
2019-04-07T19:04:01.756+0300 E QUERY [js] Error: connect failed to replica set Cluster0-shard-0/cluster0-shard-00-01-jjbdh.mongodb.net.:27017,cluster0-shard-00-02-jjbdh.mongodb.net.:27017,cluster0-shard-00-00-jjbdh.mongodb.net.:27017 :
connect@src/mongo/shell/mongo.js:343:13
@(connect):2:6
exception: connect failed
and
.\mongo.exe "mongodb://root:password@cluster0-shard-00-00-jjbdh.mongodb.net:27017/admin"
MongoDB shell version v4.0.8
connecting to: mongodb://cluster0-shard-00-00-jjbdh.mongodb.net:27017/admin?gssapiServiceName=mongodb
2019-04-07T19:17:19.420+0300 E QUERY [js] Error: network error while attempting to run command 'isMaster' on host 'cluster0-shard-00-00-jjbdh.mongodb.net:27017' :
connect@src/mongo/shell/mongo.js:343:13
@(connect):2:6
exception: connect failed