Greetings,
I'm attempting to connect my Node.js application to my Cosmos DB for MongoDB but have been unsuccessful. I've attempted numerous methods, including deleting and recreating the database. Connections are allowed from all networks, but I can't connect to my database directly from mongosh. I keep receiving the following error:
Connecting to: mongodb://<credentials>@mydb.mongo.cosmos.azure.com:10255/?ssl=true&retrywrites=false&maxIdleTimeMS=120000&appName=%40mydb%40&directConnection=true MongoNetworkError: connect ECONNREFUSED dbIP:10255
I don't believe the issue lies within my Node.js code as I'm receiving the same error as above. However, the error code from my Node.js application may provide some insight:
javascript
Failed dbIP:10255
at Topology.selectServer (C:\Users\Jordan\Downloads\Website\api\node_modules\mongodb\lib\sdam\topology.js:303:38)
at async Topology._connect (C:\Users\Jordan\Downloads\Website\api\node_modules\mongodb\lib\sdam\topology.js:196:28)
at async Topology.connect (C:\Users\Jordan\Downloads\Website\api\node_modules\mongodb\lib\sdam\topology.js:158:13)
at async topologyConnect (C:\Users\Jordan\Downloads\Website\api\node_modules\mongodb\lib\mongo_client.js:204:17)
at async MongoClient._connect (C:\Users\Jordan\Downloads\Website\api\node_modules\mongodb\lib\mongo_client.js:217:13)
at async MongoClient.connect (C:\Users\Jordan\Downloads\Website\api\node_modules\mongodb\lib\mongo_client.js:142:13) {
reason: TopologyDescription {
type: 'ReplicaSetNoPrimary',
servers: Map(1) {
'mydb.mongo.cosmos.azure.com:10255' => [ServerDescription]
},
stale: false,
compatible: true,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
setName: 'globaldb',
maxElectionId: null,
maxSetVersion: null,
commonWireVersion: 0,
logicalSessionTimeoutMinutes: null
},
code: undefined,
[Symbol(errorLabels)]: Set(0) {},
[cause]: MongoNetworkError: connect ECONNREFUSED dbip:10255
at connectionFailureError (C:\Users\Jordan\Downloads\Website\api\node_modules\mongodb\lib\cmap\connect.js:353:20)
at TLSSocket.<anonymous> (C:\Users\Jordan\Downloads\Website\api\node_modules\mongodb\lib\cmap\connect.js:268:44)
at Object.onceWrapper (node:events:635:26)
at TLSSocket.emit (node:events:520:28)
at emitErrorNT (node:internal/streams/destroy:170:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
[Symbol(errorLabels)]: Set(1) { 'ResetPool' },
[cause]: Error: connect ECONNREFUSED dbip:10255
at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1605:16) {
errno: -4078,
code: 'ECONNREFUSED',
syscall: 'connect',
address: 'dbip',
port: 10255
}
}
}
I've disabled my firewall to ensure that it's not blocking my connection, but I still can't access my database. Can anyone offer some advice on how to troubleshoot this issue?
Thank you kindly.