【发布时间】:2020-05-27 21:48:12
【问题描述】:
我将 Strapi CMS 部署到 Heroku,但出现此错误
连接到 Mongo 数据库时出错。服务器选择在 30000 毫秒后超时
日志:
2020-05-27T17:43:55.398256+00:00 heroku[web.1]: Starting process with command `npm start`
2020-05-27T17:43:58.724121+00:00 app[web.1]:
2020-05-27T17:43:58.724143+00:00 app[web.1]: > strapi-oskogen-mongodb@0.1.0 start /app
2020-05-27T17:43:58.724143+00:00 app[web.1]: > strapi start
2020-05-27T17:43:58.724143+00:00 app[web.1]:
2020-05-27T17:44:02.234160+00:00 app[web.1]: (node:23) Warning: Accessing non-existent property 'count' of module exports inside circular dependency
2020-05-27T17:44:02.234179+00:00 app[web.1]: (Use `node --trace-warnings ...` to show where the warning was created)
2020-05-27T17:44:02.234732+00:00 app[web.1]: (node:23) Warning: Accessing non-existent property 'findOne' of module exports inside circular dependency
2020-05-27T17:44:02.234879+00:00 app[web.1]: (node:23) Warning: Accessing non-existent property 'remove' of module exports inside circular dependency
2020-05-27T17:44:02.235021+00:00 app[web.1]: (node:23) Warning: Accessing non-existent property 'updateOne' of module exports inside circular dependency
2020-05-27T17:44:32.238852+00:00 app[web.1]: [2020-05-27T17:44:32.238Z] debug ⛔️ Server wasn't able to start properly.
2020-05-27T17:44:32.253150+00:00 app[web.1]: [2020-05-27T17:44:32.253Z] error Error connecting to the Mongo database. Server selection timed out after 30000 ms
我的环境设置:
database.js
** server.js **
** response.js **
** 配置变量 **
站点在本地主机上运行良好,具有开发和生产环境。所以它连接到 Atlas 上的 MongoDB 并没有问题。
我没有在 Heroku 上安装任何插件。
** 包.json **
在 Atlas 方面,我在白名单中打开了所有 IP。
有什么想法吗?谢谢! :)
【问题讨论】:
-
您解决了这个问题吗?我目前遇到同样的问题,无法解决。
-
尝试更改 Server.js ---> 端口 443 使其工作。 module.exports = ({ env }) => ({ host: env('HOST', '0.0.0.0'), port: env.int('PORT', 443), });如果它不起作用,我可以给你我的配置。
-
感谢您的回复,但没有运气。如果您能分享您的配置将不胜感激,因为我非常困惑为什么这不起作用。我的配置都在my own stack question
-
我现在得走了。我可以在周末回答吗? :)
-
太棒了,非常感谢!周末愉快:)
标签: mongodb heroku strapi heroku-cli