1

I'm follow this guide to setting up an app with a data base (https://www.mongodb.com/languages/mern-stack-tutorial).

I'm at the step where I have everything installed and an Atlas account set up. I'm trying to connect to my database from VS Code but every time I try it it gives me this

code: 8000,
  codeName: 'AtlasError',
  connectionGeneration: 0,
  [Symbol(errorLabels)]: Set(2) { 'HandshakeError', 'ResetPool' }

All the links that I have looked for related issues on AtlasError or error code 8000s would tell me to not include the <> that is put in with the and in the Atlas URI mongodb+srv://<username>:<password>@sandbox.jadwj.mongodb.net/employees?retryWrites=true&w=majority. Other suggestions have been to use the username and password that has access to the database rather than the account which have been made certain of.

I tried looking up error labels in the documentation but I don't see anything.

This is the whole output.

Server is running on port: 5000
MongoServerError: bad auth : Authentication failed.
    at Connection.onMessage (C:\Users\Alexander Chea\Desktop\Starz\mern\server\node_modules\mongodb\lib\cmap\connection.js:227:30)
    at MessageStream.<anonymous> (C:\Users\Alexander Chea\Desktop\Starz\mern\server\node_modules\mongodb\lib\cmap\connection.js:60:60)
    at MessageStream.emit (node:events:513:28)
    at processIncomingData (C:\Users\Alexander Chea\Desktop\Starz\mern\server\node_modules\mongodb\lib\cmap\message_stream.js:125:16)
    at MessageStream._write (C:\Users\Alexander Chea\Desktop\Starz\mern\server\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' }
}

Any help would be appreciated, thanks.

cheaseeds
  • 21
  • 2

1 Answers1

0

Try to remove employees from the URL path because Atlas already knows which database are you using

  • Yeah I think I come to the conclusion that they were not getting to the right point together (if that's the right term). I was trying to create a db under the name starz yet the default that I copied from the guide was using employees as the db. I'm still confused with this part and the difference between clusters, collections, and databases. – cheaseeds Dec 21 '22 at 11:24
  • Hmm... good question @cheaseeds Actually, the collections are the collection of each record you are trying to write to a database ( for example a purpose of creating collections named users and books is that they are very different in the data structure themselves [ book has pages but users have credit cards ) and you can have multiple databases but it's not mandatory most of the times and the clusters are just databases but will get deployed in multiple regions and can be even deployed with multiple nodes ( that's why they are called clusters ) – Mohammad Hosein Balkhani Dec 21 '22 at 11:40