返回代码:1 stdout:
email protected(https://stackoverflow.com/cdn-cgi/l/email-protection) start node App.js stderr:MongoDB连接错误:MongoServerSelectionError:无法获取本地颁发者证书,位于进程.processTimers(node:internal/timers:512:7)中的listOntario(node:internal/timers:569:17)的ontario(/home/ipamania/nodevenv/app.ipamania/18/lib/node_modules/mongodb/lib/sdam/topology.js:278:38){原因:TopologyDescription { type:'ReplicaSetNoPrimary',服务器: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] },陈旧:false,兼容:true,heartbeatFrequencyMS:10000,localThresholdMS:15、setName:'atlas-10qwe6-shard-0',maxElectionId:null,maxSetVersion:null,commonWireVersion:0,logicalSessionTimeoutMinutes:null },代码:undefined,[Symbol(errorLabels)]:设置(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
当我尝试在cpanel中部署我的node应用程序时,我得到了这个错误。
1条答案
按热度按时间zujrkrfu1#
这是node.js驱动程序中的PKI证书验证失败。
具体来说,驱动程序使用TLS连接到服务器,服务器提供它的证书,并且可能包括中间证书。然后,驱动程序尝试验证该证书上的数字签名,但无法找到颁发该服务器证书的根证书。
您需要将驱动程序配置为接受未经验证的证书,或获取Atlas使用的根证书(请参阅哪个证书颁发机构签署MongodB Atlas TLS证书)