MongoDB and Mongoose - Create and Save a Record of a Model

Tell us what’s happening:
I got this error message

callback(new MongoError(document));

MongoError: bad auth : Authentication failed.
at MessageStream.messageHandler (/home/runner/boilerplate-mongomongoose/node_modules/mongodb/lib/cmap/connection.js:299:20)
at MessageStream.emit (node:events:390:28)
at processIncomingData (/home/runner/boilerplate-mongomongoose/node_modules/mongodb/lib/cmap/message_stream.js:144:12)
at MessageStream._write (/home/runner/boilerplate-mongomongoose/node_modules/mongodb/lib/cmap/message_stream.js:42:5)
at writeOrBuffer (node:internal/streams/writable:389:12)
at _write (node:internal/streams/writable:330:10)
at MessageStream.Writable.write (node:internal/streams/writable:334:10)
at TLSSocket.ondata (node:internal/streams/readable:754:22)
at TLSSocket.emit (node:events:390:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at TLSSocket.Readable.push (node:internal/streams/readable:228:10)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:199:23) {
ok: 0,
code: 8000,
codeName: ‘AtlasError’

Your project link(s)

solution: boilerplate-mongomongoose - Node.js Repl - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: MongoDB and Mongoose - Create and Save a Record of a Model

Link to the challenge:

Did you make sure you the username and password specified in the MONGO_URI has read/write permissions?

  • Under Database User Privileges, leave this as the default option, Read and write to any database.

I had to add specific privilege ! Thanks

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.