question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Mongo Error on Deno runtime

See original GitHub issue

Hello I have tried to run a project on deno, but I receive the following error when trying to run it using “deno”

error: Uncaught Error: MongoError: "Connection failed: Connection refused (os error 111)"
        throw new MongoError(`Connection failed: ${e.message || e}`);
              ^
    at MongoClient.connect (client.ts:93:15)
    at async db.ts:5:12

Note:

I have tried it several times but the problem still persists.

Thanks in advance

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
hackers267commented, Feb 2, 2021

If you used os is window. Try replace localhost with 127.0.0.1

1reaction
NaderBhrrcommented, Feb 1, 2021

Thanks for the reply

I have allocated a separate module for database namely db.ts


import { MongoClient } from "https://deno.land/x/mongo@v0.21.2/mod.ts";

const client = new MongoClient();
// await client.connect("mongodb://localhost:27017");
const db = await client.connect("mongodb://localhost:27017/kayran");

export * from "https://deno.land/x/mongo@v0.21.2/mod.ts";

export default db;

Please note that, I did successfully launched my project but after a few re-run deno stopped creating the server and currently it is showing the above error

Thank you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Mongo Error on Deno runtime · Issue #177 - GitHub
Hello I have tried to run a project on deno, but I receive the following error when trying to run it using "deno"...
Read more >
/src/error.ts | mongo@v0.28.0 | Deno
import * as mongo from "https://deno.land/x/mongo@v0.28.0/src/error.ts";. Deno Logo. Why Deno? Develop LocallyDeploy GloballyCompare to Node.jsBenchmarks.
Read more >
How to Setup and Use MongoDB with Deno 2022 - CodevoWeb
Step 4 – Connect Deno to MongoDB Server​​ Now that we have the MongoDB Docker container running, let's create a utility function to...
Read more >
Getting Started with Deno & MongoDB
Deno is a “modern” runtime for JavaScript and TypeScript that is built in ... If the request doesn't have a body it will...
Read more >
Deno app getting "Connection failed: Connection refused (os error ...
Where is Mongo running? Is it possible it's trying to connect over IPv6 but Mongo is only listening on IPv4? asyrique ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found