【发布时间】:2022-08-02 18:15:56
【问题描述】:
在 CPanel 中运行应用程序时 enter image description here
我有这个错误:
MongoServerSelectionError:连接 ECONNREFUSED 13.xxx.xx.xxxx:27017
在CPanel仪表板中,我added这个IP地址到防火墙
在MongoDB Atlass网络接口,我addedCPanel服务器ip地址:
这是完整的日志:
MongoServerSelectionError: connect ECONNREFUSED 13.xxx.xx.xx:27017 at Timeout._onTimeout (/home/c1439621c/nodevenv/my-app-server/14/lib/node_modules/mongodb/lib/sdam/topology.js:312:38) at listOnTimeout (internal/timers.js:557:17) at processTimers (internal/timers.js:500:7) { reason: TopologyDescription { type: \'ReplicaSetNoPrimary\', servers: Map(3) { \'ac-fgw9tmo-shard-00-00.inp06zb.mongodb.net:27017\' => [ServerDescription], \'ac-fgw9tmo-shard-00-01.inp06zb.mongodb.net:27017\' => [ServerDescription], \'ac-fgw9tmo-shard-00-02.inp06zb.mongodb.net:27017\' => [ServerDescription] }, stale: false, compatible: true, heartbeatFrequencyMS: 10000, localThresholdMS: 15, setName: \'atlas-109adn-shard-0\', logicalSessionTimeoutMinutes: undefined } }
-
1)你已经有一个允许世界连接的防火墙规则,所以这不是防火墙问题,而是潜在的安全问题。 2)错误是ReplicaSetNoPrimary. 3)您的副本设置不正确,连接字符串格式不正确等。这些细节不在您的问题中。 4) 根据副本 URL,您正在连接到 Atlas,因此问题出在您的应用程序上。
-
@JohnHanley,它在本地和 Heroku 中完美运行,我认为问题出在 cpanel 主机上
-
什么在本地和 Heroku 中完美运行?
标签: node.js mongodb cpanel parse-server mongodb-atlas