-
Type: Bug
-
Resolution: Done
-
Priority: Unknown
-
None
-
Affects Version/s: None
-
Component/s: Connection String
What problem are you facing?
When I try to connect to mongodb using localhost as the hostname it resolves to IPv6 shorthand [::1] but the mongodb server is listening on IPv4 127.0.0.1
It should try to connect over IPv6 and if it fails then try to connect over IPv4
What driver and relevant dependency versions are you using?
Mongodb for node driver version 4.10.0
Typeorm/mongoose: 0.3.10 / 6.6.4
Nodejs v18.9.0
Using mongodb server 6.0.2 for windows community edition
I have windows 11 22H2 Pro
Steps to reproduce?
Nothing much in terms of environment since windows enable IPv6 by default
1. npm init -y
2. npm i --save mongoose
// mongodb.js const mongoose = require('mongoose'); main().catch(err => console.log(err)); async function main() { await mongoose.connect('mongodb://<user>:<pwd>@localhost:27017/<database>?authMechanism=DEFAULT'); console.log("Connected") mongoose.disconnect(); }
4. node mongodb.js
following this steps will result in the same error shown in the screenshot attached
- is related to
-
NODE-4926 Support autoSelectFamily and autoSelectFamilyAttemptTimeout in options
- Closed