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

fix: how to connect to local MongoDB instance #351

Merged
merged 1 commit into from
Apr 27, 2022

Conversation

filipe-freire
Copy link
Contributor

The current step on how to connect to a local MongoDB instance can cause the error detailed in the following issue:
#170

The proposed changes aim to fix that by replacing the "mongodb://localhost:27017" with "mongodb://127.0.0.1:27017".

This fixed was submitted by @michaeldesu in the issue linked above.

The current step on how to connect to a local MongoDB instance can cause the error detailed in the following issue:
denodrivers#170

The proposed changes aim to fix that by replacing the "mongodb://localhost:27017" with "mongodb://127.0.0.1:27017".

This fixed was submitted by @michaeldesu in the issue linked above.
@filipe-freire filipe-freire requested a review from erfanium as a code owner April 27, 2022 10:36
@lucsoft
Copy link
Collaborator

lucsoft commented Apr 27, 2022

Is this a windows only thing?

On Linux and macOS it's completely the same?

I don't see how this changes anything?
Or is the issue something else?

@filipe-freire
Copy link
Contributor Author

Can only speak for Linux as I found this issue today running PopOS 22.04 LTS. Following the current instructions in the docs returns the following error:

Error: MongoError: "Connection failed: Connection refused (os error 111)"
      throw new MongoDriverError(`Connection failed: ${e.message || e}`);
            ^
    at MongoClient.connect (https://deno.land/x/mongo@v0.29.4/src/client.ts:44:13)

That ceases to happen once we replace await client.connect("mongodb://localhost:27017"); for await client.connect("mongodb://127.0.0.1:27017");

@lucsoft
Copy link
Collaborator

lucsoft commented Apr 27, 2022

I don't like the solution to this problem

localhost is 127.0.0.1 and ::1

We should dig a bit more into it.
Not just changing the readme.
People will still use localhost

Copy link
Collaborator

@lucsoft lucsoft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a deno_mongo error? Or is this a Deno error even?

@filipe-freire
Copy link
Contributor Author

filipe-freire commented Apr 27, 2022

I would still change the docs to use 127.0.0.1 so long as the root cause of this issue is not identified & fixed. At least then users wouldn't face issues while setting up deno_mongo for the first time.

But ideally, like you mentioned, both ways should work interchangeably. 😃

@erfanium
Copy link
Member

@filipe-freire can you help me how i can reproduce this issue in Ubuntu?

@filipe-freire
Copy link
Contributor Author

@erfanium I can sure try :) The issue occurs when running a file with the following code:

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

const client = new MongoClient();

// Connecting to a Local Database
await client.connect("mongodb://localhost:27017");

You can run the file with the following flags: deno run --allow-net app.ts

The output should be the following error:

error: Uncaught (in promise) Error: MongoError: "Connection failed: Connection refused (os error 111)"
      throw new MongoDriverError(`Connection failed: ${e.message || e}`);
            ^
    at MongoClient.connect (https://deno.land/x/mongo@v0.29.4/src/client.ts:44:13)

@erfanium
Copy link
Member

I would still change the docs to use 127.0.0.1 so long as the root cause of this issue is not identified & fixed

I'm okay with that

@erfanium erfanium merged commit 2566090 into denodrivers:main Apr 27, 2022
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

Successfully merging this pull request may close these issues.

3 participants