Next.js Discord

Discord Forum

I can't connect the mongodb api

Unanswered
MR.Robot posted this in #help-forum
Open in Discord
Avatar
MR.RobotOP
I've been dealing with this error for 2 hours and I can't connect mongodb. can anyone help me with this?
Image

11 Replies

Essentially, your connection url is probably wrong
Avatar
joulev
@MR.Robot that connection string is secret, don’t post it here. I removed the message. Are you absolutely sure it doesn’t have any mistakes mentioned in the link above?
Avatar
MR.RobotOP
bad auth : authentication failed
⨯ lib\utils.ts (18:11) @ handleError
⨯ Error: Error: bad auth : authentication failed
at handleError (./lib/utils.ts:30:15)
at getAllImages (./lib/actions/image.actions.ts:130:60)
at async Home (page.tsx:21:20)
digest: "1379115389"
16 | // This is a native JavaScript error (e.g., TypeError, RangeError)
17 | console.error(error.message);
18 | throw new Error(Error: ${error.message});
| ^
19 | } else if (typeof error === "string") {
20 | // This is a string error message
21 | console.error(error);
⨯ lib\utils.ts (18:11) @ handleError
⨯ Error: Error: bad auth : authentication failed
at handleError (./lib/utils.ts:30:15)
at getAllImages (./lib/actions/image.actions.ts:130:60)
at async Home (page.tsx:21:20)
digest: "1379115389"
16 | // This is a native JavaScript error (e.g., TypeError, RangeError)
17 | console.err
this error
Avatar
joulev
Can you query the database with [mongodb compass](https://www.mongodb.com/products/tools/compass)? If the connection string is correct, it should work there, if not you need to fix your connection string first
Avatar
MR.RobotOP
I'm querying with mongoose.
Avatar
joulev
Yes I know. But I want to ensure that the connection string is correct. Download compass and use it to inspect the database with a connection string, does it work?
Avatar
MR.RobotOP
https://www.youtube.com/watch?v=Ahwoks_dawU&t=59s this video watch mongodb connect
I'm connected with compass
but I could not connect in my own project