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

connecting to MongoDB Atlas, #14917

Open
2 tasks done
Joshua-alt opened this issue Sep 30, 2024 · 14 comments
Open
2 tasks done

connecting to MongoDB Atlas, #14917

Joshua-alt opened this issue Sep 30, 2024 · 14 comments
Labels
needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity

Comments

@Joshua-alt
Copy link

Joshua-alt commented Sep 30, 2024

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the bug has not already been reported

Mongoose version

8

Node.js version

18.14.1

MongoDB server version

MongoDB Atlas

Typescript version (if applicable)

No response

Description

I’m encountering a problem connecting to MongoDB Atlas, even though I’ve allowed network access for everyone by adding ‘0.0.0.0/0’ to the IP whitelist using mongoose v8

Steps to Reproduce

to get issue that i show in description can be done by install mongoose 8v then connect it with mongodb atlas
and to fixe required to back on "mongoose": "^7.3.2" version that for me is working fine

Expected Behavior

I’m encountering a problem connecting to MongoDB Atlas, even though I’ve allowed network access for everyone by adding ‘0.0.0.0/0’ to the IP whitelist. When attempting to connect, I consistently receive the following error message: ‘MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you’re trying to access the database from an IP that isn’t whitelisted. Make sure your current IP address is on your Atlas cluster’s IP whitelist

@akang
Copy link

akang commented Oct 1, 2024

I am facing the same issue.

For me:

Breaks on version 8.7.0
Works on 8.5.2

@mtrplx
Copy link

mtrplx commented Oct 1, 2024

worked for me too!! thank u very much i was going INSANE

@vkarpov15
Copy link
Collaborator

What version of the MongoDB server are you running in Atlas?

@vkarpov15 vkarpov15 added the needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity label Oct 2, 2024
@akang
Copy link

akang commented Oct 2, 2024

@vkarpov15

7.0.12

@mtrplx
Copy link

mtrplx commented Oct 3, 2024

7.0.14

@kumarchetan-1
Copy link

Yes, "mongoose": "^7.0.12" is working for me.
Thank you @akang!

@vkarpov15
Copy link
Collaborator

A couple of potential suggestions:

  1. Does your database username or password contain special characters that would be encoded by encodeURIComponent()?
  2. Are you able to connect using the mongodb node driver?
  3. What is the output of err.reason where err is the MongooseServerSelectionError?

@lukas-becker0
Copy link

We have no issues with mongoose 8.6.4 and mongodb 7.0.12 on mongodb atlas.

@angelosnm
Copy link

Same behaviour here....mongoose 8.7.0 and mongodb atlas 8.0.0

@bmortella
Copy link

bmortella commented Oct 12, 2024

Same! Atlas 7.0.14
Fixed by rolling back to mongoose 8.6.1.

@lukas-becker0
Copy link

lukas-becker0 commented Oct 14, 2024

Strange we also use Atlas 7.0.14 now and mongoose 8.6.4 without this connection issue.

How do you guys connect to the server ?

mongodb+srv://DB-USER:PASSWORD@ATLAS-INSTANCE-NAME.dyvqc.mongodb.net/?retryWrites=true&w=majority

serverSelectionTimeoutMS is set to 5000 ms

And the DB name is not included in the URL option, it is passed separately through the mongoose dbName option.

@lukas-becker0
Copy link

We only use linux and macOS maybe this is a windows issue ?

@angelosnm
Copy link

We only use linux and macOS maybe this is a windows issue ?

Nope. I came with this issue on deployment, obviously on linux server.

@vkarpov15
Copy link
Collaborator

I tried with a separate dbName option and no dbname in the connection string, I'm still able to connect successfully to Atlas with Mongoose 8.7. @angelosnm are you able to provide any additional information?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs clarification This issue doesn't have enough information to be actionable. Close after 14 days of inactivity
Projects
None yet
Development

No branches or pull requests

8 participants