denodrivers / denodrivers/mongo

authentication error when connecting to localhost

Open
#417 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
511
Forks
89
PR merge metrics
No merged PRs in 30d

Description

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](https://github.com/user-attachments/assets/f470577a-e2e5-4935-930c-65efb9899c90)

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:pass@127.0.0.1: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:mongodb@6.9.0` 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.