mongoose: Update to 5.2.0 and reports Authentication failed
Do you want to request a feature or report a bug? bug What is the current behavior?
My code runs normal before 5.2.x but reports Authentication failed after update to 5.2
If the current behavior is a bug, please provide the steps to reproduce.
What is the expected behavior?
Please mention your node.js, mongoose and MongoDB version.
node version: 10.5.0 mongodb version: 3.4.6
const mongoConfig = {
dbName: process.env.db || "test",
pass: process.env.passwd || "",
reconnectInterval: 500,
reconnectTries: Number.MAX_VALUE,
user: process.env.user || ""
}
const uri = `mongodb://${ip}:${port}`;
const con = mongoose.createConnection(uri, mongoConfig);
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 6
- Comments: 15
This should work too:
Managed to make it work, I had to specify authSource: ‘admin’ in opts object in mongoose.createConnection(uri, opts) even though I already had that specified in the connection uri.
Connecting with the string with ?authSource=admin And connecting to DB with mongoose.createConnection