Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

339
Views
Connecting mongodb to nodejs
  1. Restarted MongoDB server (it keeps running when error occurs).

  2. Using MongoDB server on windows as a service (started it manually) Established the connection via MongoDB Shell CLI Package by hitting enter in the comand prompt to establish the default connection.

  3. (mongodb://127.0.0.1:27017/directConnection=true&serverSelectionTimeoutMS=2000 ) Called npm install and npm start (my dependencies are listed below)

  4. Checked that MongoDB is running

  5. Checked via the windows resource monitor that the port 27017 is occupied by mongod.exe using TCP and is not restricted by the firewall

  6. Checked that I am not using a VPN nor a proxy connection that could interfere.

  7. Then I opened http://localhost:3000/ to which I am listening (app.listen(3000);)

Why am i still getting this error even after trying all of the above steps?


MongoServerSelectionError: connect ECONNREFUSED ::1:27017
    at Timeout._onTimeout (C:\Users\ridwaan\Documents\web dev\test\node_modules\mongodb\lib\sdam\topology.js:330:38)
    at listOnTimeout (node:internal/timers:557:17)
    at processTimers (node:internal/timers:500:7) {
  reason: TopologyDescription {
    type: 'Unknown',
    servers: Map(1) {
      'localhost:27017' => ServerDescription {
        _hostAddress: HostAddress { isIPv6: false, host: 'localhost', port: 27017 },
        address: 'localhost:27017',
        type: 'Unknown',
        hosts: [],
        passives: [],
        arbiters: [],
        tags: {},
        minWireVersion: 0,
        maxWireVersion: 0,
        roundTripTime: -1,
        lastUpdateTime: 1717487,
        lastWriteDate: 0,
        error: MongoNetworkError: connect ECONNREFUSED ::1:27017
            at connectionFailureError (C:\Users\ridwaan\Documents\web dev\test\node_modules\mongodb\lib\cmap\connect.js:293:20)
            at Socket.<anonymous> (C:\Users\ridwaan\Documents\web dev\test\node_modules\mongodb\lib\cmap\connect.js:267:22)
            at Object.onceWrapper (node:events:510:26)
            at Socket.emit (node:events:390:28)
            at emitErrorNT (node:internal/streams/destroy:164:8)
            at emitErrorCloseNT (node:internal/streams/destroy:129:3)
            at processTicksAndRejections (node:internal/process/task_queues:83:21)
      }
    },
    stale: false,
    compatible: true,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    logicalSessionTimeoutMinutes: undefined
  }
}

Node.js v17.1.0
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!