Reputation: 31
returncode: 1 stdout:
[email protected] start node App.js stderr: MongoDB connection error: MongoServerSelectionError: unable to get local issuer certificate at Timeout._onTimeout (/home/ipamania/nodevenv/app.ipamania/18/lib/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: 'ReplicaSetNoPrimary', servers: Map(3) { 'ac-afc4vog-shard-00-00.wqdkklu.mongodb.net:27017' => [ServerDescription], 'ac-afc4vog-shard-00-01.wqdkklu.mongodb.net:27017' => [ServerDescription], 'ac-afc4vog-shard-00-02.wqdkklu.mongodb.net:27017' => [ServerDescription] }, stale: false, compatible: true, heartbeatFrequencyMS: 10000, localThresholdMS: 15, setName: 'atlas-10qwe6-shard-0', maxElectionId: null, maxSetVersion: null, commonWireVersion: 0, logicalSessionTimeoutMinutes: null }, code: undefined, [Symbol(errorLabels)]: Set(0) {} } /home/ipamania/nodevenv/app.ipamania/18/lib/node_modules/mongoose/lib/connection.js:805 err = new ServerSelectionError(); ^
MongooseServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted. Make sure your current IP address is on your Atlas cluster's IP whitelist: https://www.mongodb.com/docs/atlas/security-whitelist/ at _handleConnectionErrors (/home/ipamania/nodevenv/app.ipamania/18/lib/node_modules/mongoose/lib/connection.js:805:11) at NativeConnection.openUri (/home/ipamania/nodevenv/app.ipamania/18/lib/node_modules/mongoose/lib/connection.js:780:11) { reason: TopologyDescription { type: 'ReplicaSetNoPrimary', servers: Map(3) { 'ac-afc4vog-shard-00-00.wqdkklu.mongodb.net:27017' => ServerDescription { address: 'ac-afc4vog-shard-00-00.wqdkklu.mongodb.net:27017', type: 'Unknown', hosts: [], passives: [], arbiters: [], tags: {}, minWireVersion: 0, maxWireVersion: 0, roundTripTime: -1, lastUpdateTime: 910547387, lastWriteDate: 0, error: MongoNetworkError: unable to get local issuer certificate at connectionFailureError (/home/ipamania/nodevenv/app.ipamania/18/lib/node_modules/mongodb/lib/cmap/connect.js:367:20) at TLSSocket. (/home/ipamania/nodevenv/app.ipamania/18/lib/node_modules/mongodb/lib/cmap/connect.js:290:22) at Object.onceWrapper (node:events:628:26) at TLSSocket.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: unable to get local issuer certificate at TLSSocket.onConnectSecure (node:_tls_wrap:1540:34) at TLSSocket.emit (node:events:513:28) at TLSSocket._finishInit (node:_tls_wrap:959:8) at ssl.onhandshakedone (node:_tls_wrap:743:12) { code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY' }, [Symbol(errorLabels)]: Set(1) { 'ResetPool' } }, topologyVersion: null, setName: null, setVersion: null, electionId: null, logicalSessionTimeoutMinutes: null, primary: null, me: null, '$clusterTime': null }, 'ac-afc4vog-shard-00-01.wqdkklu.mongodb.net:27017' => ServerDescription { address: 'ac-afc4vog-shard-00-01.wqdkklu.mongodb.net:27017', type: 'Unknown', hosts: [], passives: [], arbiters: [], tags: {}, minWireVersion: 0, maxWireVersion: 0, roundTripTime: -1, lastUpdateTime: 910547400, lastWriteDate: 0, error: MongoNetworkError: unable to get local issuer certificate at connectionFailureError (/home/ipamania/nodevenv/app.ipamania/18/lib/node_modules/mongodb/lib/cmap/connect.js:367:20) at TLSSocket. (/home/ipamania/nodevenv/app.ipamania/18/lib/node_modules/mongodb/lib/cmap/connect.js:290:22) at Object.onceWrapper (node:events:628:26) at TLSSocket.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: unable to get local issuer certificate at TLSSocket.onConnectSecure (node:_tls_wrap:1540:34) at TLSSocket.emit (node:events:513:28) at TLSSocket._finishInit (node:_tls_wrap:959:8) at ssl.onhandshakedone (node:_tls_wrap:743:12) { code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY' }, [Symbol(errorLabels)]: Set(1) { 'ResetPool' } }, topologyVersion: null, setName: null, setVersion: null, electionId: null, logicalSessionTimeoutMinutes: null, primary: null, me: null, '$clusterTime': null }, 'ac-afc4vog-shard-00-02.wqdkklu.mongodb.net:27017' => ServerDescription { address: 'ac-afc4vog-shard-00-02.wqdkklu.mongodb.net:27017', type: 'Unknown', hosts: [], passives: [], arbiters: [], tags: {}, minWireVersion: 0, maxWireVersion: 0, roundTripTime: -1, lastUpdateTime: 910547165, lastWriteDate: 0, error: MongoNetworkError: unable to get local issuer certificate at connectionFailureError (/home/ipamania/nodevenv/app.ipamania/18/lib/node_modules/mongodb/lib/cmap/connect.js:367:20) at TLSSocket. (/home/ipamania/nodevenv/app.ipamania/18/lib/node_modules/mongodb/lib/cmap/connect.js:290:22) at Object.onceWrapper (node:events:628:26) at TLSSocket.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: unable to get local issuer certificate at TLSSocket.onConnectSecure (node:_tls_wrap:1540:34) at TLSSocket.emit (node:events:513:28) at TLSSocket._finishInit (node:_tls_wrap:959:8) at ssl.onhandshakedone (node:_tls_wrap:743:12) { code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY' }, [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: 'atlas-10qwe6-shard-0', maxElectionId: null, maxSetVersion: null, commonWireVersion: 0, logicalSessionTimeoutMinutes: null }, code: undefined }
Node.js v18.16.1
When i try to deploy my node app in cpanel, i got this error.
Upvotes: 3
Views: 2307
Reputation: 28376
This is a PKI certificate validation failure in the node.js driver.
Specifically, the driver is connecting to the server using TLS, the server is presenting it's certificate, and probably including an intermediate certificate. The driver then attempts to verify the digital signature on that certificate, but is not able to find the root certificate that issued that server certificate.
You will need to either configure the driver to accept unverified certificates, or obtain the root certificate used by Atlas (see Which certificate authority signs MongodB Atlas TLS certificates)
Upvotes: 3