I create a chat app using mern stack. After deploy server in vercel. but it is not work. there is a error in vercel log.
Legacy server listening... MongoServerError: bad auth : authentication failed at Connection.onMessage (/var/task/node_modules/mongoose/node_modules/mongodb/lib/cmap/connection.js:207:30) at MessageStream.<anonymous> (/var/task/node_modules/mongoose/node_modules/mongodb/lib/cmap/connection.js:60:60) at MessageStream.emit (node:events:513:28) at processIncomingData (/var/task/node_modules/mongoose/node_modules/mongodb/lib/cmap/message_stream.js:132:20) at MessageStream._write (/var/task/node_modules/mongoose/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 TLSSocket.ondata (node:internal/streams/readable:766:22) at TLSSocket.emit (node:events:513:28) { ok: 0, code: 8000, codeName: 'AtlasError', connectionGeneration: 0, [Symbol(errorLabels)]: Set(2) { 'HandshakeError', 'ResetPool' } }
I use mogoose express js
2
Answers
Check your MongoDB IP address Whitelist if you use MongoDB atlas.
Refer to this:
https://studio3t.com/knowledge-base/articles/mongodb-atlas-login-ip-whitelisting/#:~:text=To%20whitelist%20multiple%20IP%20addresses,Whitelist%20Entry%2C%20then%20click%20Confirm.
You maybe forgot to add the ip adress for mongodb access.
1.Got to mongodb
2.Click Network Access
3.Add Ip Adress
4.Click ALLOW ACCESS FROM ANYWHERE
Now you should see in the List field an Ip adress with
0.0.0.0/0