Loopback API connecting to MongoDB Atlas, fails Loopback API connecting to MongoDB Atlas, fails mongodb mongodb

Loopback API connecting to MongoDB Atlas, fails


This one worked for me:

 "db": {    "port": 27017,    "url": "mongodb+srv://user:password@cluster0-xxxxx.mongodb.net",    "database": "collectionName",    "name": "mongodb",    "connector": "mongodb"  },


Well, hopefully I didn't waste anyones time, Since I do keep looking after I post a question... I scoured the docs for the connector - not sure why I didn't before.... But using the URL argument and passing the connection string as a URL and bypassing the other arguments, worked just fine.

"loopback-test": {    "connector": "mongodb",    "name": "loopback-test",    "url": "mongodb://adminUser:pwd@cluster0-shard-00-00-xxx.mongodb.net:27017,cluster0-shard-00-01-xxx.mongodb.net:27017,cluster0-shard-00-02-xxx.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin"}

I hope that helps anyone else banging their head on the database.json arguments.

cheers - and as always - thanks for the help.


To clarify, the problem was caused by MongoDB Connection String URI being inserted into the host parameter instead of the url parameter.

The host parameter should only accept MongoDB server address, which can either be a hostname, IP address or UNIX domain socket.

You can find more information about the parameters on Loopback/MongoDB Connection Properties.