Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-4678

The driver doesn't fallback to IPv4 if IPv6 is not working

    • 0
    • 0
    • Not Needed
    • Not Needed

      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

       

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            ssaber277@gmail.com Saber Hosney
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: