**mongo details**
Connecting to: mongodb://127.0.0.1:27017/?
directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.8.0
Using MongoDB: 6.0.4
Using Mongosh: 1.8.0
**dependencies**
"dependencies": {
"express": "^4.18.2",
"mongodb": "^5.1.0"
}
>! version of mongodb installed is different from the dependency version of mongo,
is that the problem i am facing error while integrating?
**error**
D:\week 5 mongo\mongos\node_modules\mongodb\lib\sdam\topology.js:277
const timeoutError = new error_1.MongoServerSelectionError(`Server
selection timed out after ${serverSelectionTimeoutMS} ms`, this.description);
^
MongoServerSelectionError: connect ECONNREFUSED ::1:27017
at Timeout._onTimeout (D:\week 5
mongo\mongos\node_modules\mongodb\lib\sdam\topology.js:277: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: 32955488,
lastWriteDate: 0,
error: MongoNetworkError: connect ECONNREFUSED ::1:27017
at connectionFailureError (D:\week 5
mongo\mongos\node_modules\mongodb\lib\cmap\connect.js:383:20)
at Socket.<anonymous> (D:\week 5
mongo\mongos\node_modules\mongodb\lib\cmap\connect.js:307: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
},
at node:internal/main/run_main_module:23:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
integration code
const express=require("express")
const app=express()
const port=3000
const MongoClient = require('mongodb').MongoClient
MongoClient.connect('mongodb://localhost:27017/store', (err, db) => {
if (err) throw err
db.collection('items').find().toArray((err, result) => {
if (err) throw err
console.log(result)
})
})
app.listen(port)