Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

authentication error when connecting to localhost #417

Open
CaptainTux opened this issue Oct 10, 2024 · 2 comments
Open

authentication error when connecting to localhost #417

CaptainTux opened this issue Oct 10, 2024 · 2 comments

Comments

@CaptainTux
Copy link

after the V2 release I started trying to slowly migrate to deno, and after fixing all the imports it went great.
but I could not connect to mongodb, as I keep getting authentication error on localhost:
image

The code is as in the quickstart guide:

const client = new MongoClient();
await client.connect(process.env.MONGO_URI);

I was trying to run the code like this with deno v2.0.0:
deno run --env=packages/server/.env --allow-all packages/server/src/main.ts
To exhaust all possible options I also ran it with --unsafe without success.

My connection string looks like this mongodb://user:[email protected]:27017/?authMechanism=SCRAM-SHA-1&tls=false which is used via SSH forwarding (and yes I also verified that the URI is correct at runtime with console.log).

This error happened both with this package and with the npm:[email protected] package.
When using the npm package, the exact same code works in node, so I really don't have a clue what's going on.
I also put up a local mongodb in docker without auth, and that one does in fact work.

@lucsoft
Copy link
Collaborator

lucsoft commented Oct 10, 2024

is there a reason why you define ?authMechanism=SCRAM-SHA-1&tls=false

And if you say it also happens with the nodejs package then can you try to use your mongo uri in MongoDB Compass?

@CaptainTux
Copy link
Author

I proxy through localhost so there is no SSL configured, and in node it didn't work without specifying the auth mechanism.
and maybe I should have been more clear, it doesn't work with the npm package when running it with deno, it does connect if I run my app with node 20.17.
and I just checked, it does connect with that URI in MongoDBCompass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants