KothariG
Getting error on mongoDB connection
Am getting error when connecting to mongoDB hosted on railway.app
when using the connection uri without database name i.e. mongodb://user:[email protected]:24727
it works fine and connects
but on using uri with db name
mongodb://user:[email protected]:24727/dbname
gives authentication error
MongoServerError: Authentication failed.
at Connection.onMessage (/app/node_modules/mongodb/lib/cmap/connection.js:205:26)
at MessageStream.<anonymous> (/app/node_modules/mongodb/lib/cmap/connection.js:64:60)
at MessageStream.emit (node:events:517:28)
at processIncomingData (/app/node_modules/mongodb/lib/cmap/message_stream.js:117:16)
at MessageStream._write (/app/node_modules/mongodb/lib/cmap/message_stream.js:33:9)
at writeOrBuffer (node:internal/streams/writable:392:12)
at _write (node:internal/streams/writable:333:10)
at Writable.write (node:internal/streams/writable:337:10)
at Socket.ondata (node:internal/streams/readable:777:22)
at Socket.emit (node:events:517:28) {
ok: 0,
code: 18,
codeName: 'AuthenticationFailed',
connectionGeneration: 1,
[Symbol(errorLabels)]: Set(2) { 'HandshakeError', 'ResetPool' }
}
16 replies