i already whitelisted my ip but still error but if i set ip to 0.0.0.0/0 it works but i dont want to set it to 0.0.0.0/0 i want to set it to my own ip address. do you have any solution?
I added the IP address to the whitelist but it didn’t work. Even using 0.0.0.0
It happened to me when I upgraded mongo node.js driver from 6.3.0 to 6.9.0.
Downgrading back to 6.3.0 and the issue is gone.
downgrading to 6.3 worked for me too
update: I updated my node version the latest LTS (v20.17.0) and everything is working fine with the new driver
it seems there is an issuea with “6.9.0”, downgrading “6.1.0” (which I use my older projects) worked for me
This worked for me too!! thanks !
Apparently, the issue is on version 6.9.0 which contains a breaking change:
Here are two ways I found to overcome this issue:
- downgrading to a lower version (6.8.2 for ex)
- passing
autoSelectFamily: false
overriding the default value of true
Hope someone on MongoDB will see this discussion and revert this breaking change, or alternatively - document this as a breaking change on their release notes.
P.S.
I would totally understand if this new behavior was communicated on previous release notes, allowing developers to get prepared for that (+ adding a runtime warning might do as well), but since I didn’t find any evidence for that - it is a breaking change published out on 6.9.0 without any prior notification.
upgrading to latest node version worked for me as well!
Thanks alot man this is really helpoed me with option 2 adding the autoSelectFamily: false
Here a code that solve the issue for me:
const { MongoClient } = require("mongodb");
const uri =
"mongodb+srv://<name>:<pw>@<server>/<db></db>?retryWrites=true&w=majority";
const client = new MongoClient(uri, {
tls: true,
serverSelectionTimeoutMS: 3000,
autoSelectFamily: false,
});
async function connectToDatabase() {
try {
await client.connect();
console.log("Connected to MongoDB successfully.");
// Add your database operations here
} catch (error) {
console.error("Connection failed", error);
} finally {
await client.close();
}
}
connectToDatabase();
Amazing, Option 2 was a life saver!
autoSelectFamily: false - This was what I needed. Thanks!
if you mongoose version is 8> the problen never disapire you need to use a old version like 6 or 7 that resolved the error
Than you so much, I’m new to Mongodb so this was very frustrating experience… Youre suggestion to use autoSelectFamily: false
solved the problem!
i know im mssing the version but wont work still
Im trying to connect to my database from Render, when i do it locally it works but when i deploy my app on render it dosent i get the same error i tried lowering the version and autoSelectFamily false but nothing works
const client = new MongoClient(uri, {
serverApi: {
autoSelectFamily: false
},
});
this is my client idk if here is the problem or what, im using atlas and put the 0.0.0.0 to allow all conections but nothing
this error comes me to and i just install the latest version and the error gone. there is the comment npm i mongodb@latest
I upgraded to node version 20 along with “mongodb”: “^6.12.0”,
It solved the issue.
Add 0.0.0.0/0 as an IP address (if at all security is not your concern) in network access tab
New & Unread Topics
Topic | Replies | Views | Activity |
---|---|---|---|
How to use conditions inside projections.computed? | 1 | 343 | May 2024 |
Question on Specifying Path for Data Federation in Atlas MongoDB TimeSeries Collection | 0 | 430 | Jun 2024 |
Issue connecting to Federated in Atlas | 0 | 152 | Aug 2024 |
Need Suggestions for Reducing Downtime During Deployments with DB migration | 0 | 183 | Aug 2024 |
How to change highlight snippets size | 1 | 137 | Aug 2024 |