将 Node/MongoDB Atlas 应用程序部署到 Heroku - Heroku 无法连接到 Mongo 集群

时间:2021-07-27 19:56:31

标签: node.js mongodb heroku deployment mongodb-atlas

我正在尝试将我的 Node/MongoDB Atlas 应用程序部署到 Heroku。我已成功构建应用程序,并已按照 this MongoDB guide 的指示将所有 IP 列入白名单。我还正确地将所有必要的数据库信息添加到我的 Heroku 环境变量中。在 heroku 构建成功并尝试打开我的应用程序后,我遇到了一个应用程序错误,提示我通过运行 heroku logs --tail 检查我的日志。当我这样做然后刷新页面时,我在日志中收到以下响应:

2021-07-27T19:24:51.000000+00:00 app[api]: Build started by user /* me */
2021-07-27T19:25:13.881043+00:00 app[api]: Deploy e6e77396 by user /* me */
2021-07-27T19:25:13.881043+00:00 app[api]: Release v7 created by user /* me */
2021-07-27T19:25:14.000000+00:00 app[api]: Build succeeded
2021-07-27T19:25:14.115698+00:00 heroku[web.1]: State changed from crashed to starting
2021-07-27T19:25:17.927399+00:00 heroku[web.1]: Starting process with command `npm run start`
2021-07-27T19:25:23.594212+00:00 app[web.1]: 
2021-07-27T19:25:23.594263+00:00 app[web.1]: > quicknote-backend@1.0.0 start /app
2021-07-27T19:25:23.594263+00:00 app[web.1]: > node index.js
2021-07-27T19:25:23.594264+00:00 app[web.1]: 
2021-07-27T19:25:58.387434+00:00 app[web.1]: 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://docs.atlas.mongodb.com/security-whitelist/
2021-07-27T19:25:59.248154+00:00 heroku[web.1]: Process exited with status 0
2021-07-27T19:25:59.346768+00:00 heroku[web.1]: State changed from starting to crashed

随后是几个失败的 GET 请求。如前所述,我的 Atlas 白名单设置为接受所有 IP,所以我不确定为什么会收到此错误。有什么见解吗?

0 个答案:

没有答案