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

Cannot connect MongoClient to IPv6 localhost on Node.js 17

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Unknown Unknown
    • None
    • Affects Version/s: None
    • Component/s: None
    • 5
    • Needed

      What problem are you facing?

      MongoServerSelectionError: connect ECONNREFUSED ::1:27017
          at Timeout._onTimeout (/Users/neal/code/drivers/js/driver-v4/src/sdam/topology.ts:618:30)
          at listOnTimeout (node:internal/timers:559:17)
          at processTimers (node:internal/timers:502:7) {
        reason: TopologyDescription {
          type: 'Unknown',
          servers: Map(1) { 'localhost:27017' => [ServerDescription] },
          stale: false,
          compatible: true,
          heartbeatFrequencyMS: 10000,
          localThresholdMS: 15,
          logicalSessionTimeoutMinutes: undefined
        },
        code: undefined
      }
      

      What driver and relevant dependency versions are you using?

      Node.js v17.7.1

      Steps to reproduce?

      import { MongoClient } from './src/index';
      
      const client = new MongoClient('mongodb://bob:pwd123@localhost:27017/', {
        serverSelectionTimeoutMS: 1000,
        // family: 4 <- this arg fixes it, but it shouldn't become a requirement
      });
      
      async function main(args) {
        await client.connect();
        console.log('connected');
      }
      
      main(process.argv)
        .then(console.log)
        .catch(console.error)
        .finally(() => client.close());
      

      Acceptance Criteria

      • Fix localhost connection issue on Node.js 17
      • Verify the fix locally

            Assignee:
            neal.beeken@mongodb.com Neal Beeken
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Bailey Pearson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: