I am new to mongodb . I am using nodejs comunicate with mongodb server but it throws an error any one help me

const mongoClient=require("mongodb").MongoClient;
const connectionString="mongodb://localhost:27017"
    if(!err) {
        console.log("Connected successfully");
const timeoutError = new error_1.MongoServerSelectionError(`Server selection timed out after ${serverSelectionTimeoutMS} ms`, this.description);

MongoServerSelectionError: connect ECONNREFUSED ::1:27017
    at Timeout._onTimeout (C:\Users\vv jagadeesh\Desktop\node_practise\MEN\mongodb1\node_modules\mongodb\lib\sdam\topology.js:278:38)
    at listOnTimeout (node:internal/timers:569:17)
    at process.processTimers (node:internal/timers:512:7) {
  reason: TopologyDescription {
    type: 'Unknown',
    servers: Map(1) {
      'localhost:27017' => ServerDescription {
        address: 'localhost:27017',
        type: 'Unknown',
        hosts: [],
        passives: [],
        arbiters: [],
        tags: {},
        minWireVersion: 0,
        maxWireVersion: 0,
        roundTripTime: -1,
        lastUpdateTime: 97501159,
        lastWriteDate: 0,
        error: MongoNetworkError: connect ECONNREFUSED ::1:27017
            at connectionFailureError (C:\Users\vv jagadeesh\Desktop\node_practise\MEN\mongodb1\node_modules\mongodb\lib\cmap\connect.js:370:20)
            at Socket.<anonymous> (C:\Users\vv jagadeesh\Desktop\node_practise\MEN\mongodb1\node_modules\mongodb\lib\cmap\connect.js:293:22)
            at Object.onceWrapper (node:events:628:26)
            at Socket.emit (node:events:513:28)
            at emitErrorNT (node:internal/streams/destroy:151:8)
            at emitErrorCloseNT (node:internal/streams/destroy:116:3)
            at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {     
          cause: Error: connect ECONNREFUSED ::1:27017
              at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) {
            errno: -4078,
            code: 'ECONNREFUSED',
            syscall: 'connect',
            address: '::1',
            port: 27017
          [Symbol(errorLabels)]: Set(1) { 'ResetPool' }
        topologyVersion: null,
        setName: null,
        setVersion: null,
        electionId: null,
        logicalSessionTimeoutMinutes: null,
        primary: null,
        me: null,
        '$clusterTime': null
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    setName: null,
    maxElectionId: null,
    maxSetVersion: null,
    commonWireVersion: 0,
    logicalSessionTimeoutMinutes: null
  code: undefined,
  [Symbol(errorLabels)]: Set(0) {}

Search the forum for ECONNREFUSED and IPv6.

Good day pls am also having the same issues. Please how will I search for the ipv6 something in the forum like u said, though I saw the owner of this post under tagged suggested post by mongodb, when I typed “ipv6” it showed nothing in the search bar, pls the image below will explain better

This topic was automatically closed after 179 days. New replies are no longer allowed.