简体   繁体   English

MongoDB 和 Heroku 部署

[英]MongoDB and Heroku Deployment

Alright stuck here.好吧卡在这里。 This app - https://budget-vacation-offline.herokuapp.com/ .这个应用程序 - https://budget-vacation-offline.herokuapp.com/

I have added my environment variables to Heroku as well.我也将我的环境变量添加到 Heroku。 There is an error in the console too regarding the mongo.network.控制台中也有关于 mongo.network 的错误。 What am I missing?我错过了什么? Happy to link the repository if needed.如果需要,很高兴链接存储库。 This is my error locally.这是我在本地的错误。

App running on port 7894: (node:1177) UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [Error.在端口 7894 上运行的应用程序:(节点:1177)UnhandledPromiseRejectionWarning:MongoNetworkError:首次连接时无法连接到服务器 [localhost:27017] [错误。 connect ECONNREFUSED 127.0.0:1:27017连接 ECONNREFUSED 127.0.0:1:27017

The error mean that your app need to connect to an instance of mongodb, which not available on the address you set(localhost).该错误意味着您的应用程序需要连接到 mongodb 的实例,该实例在您设置的地址(本地主机)上不可用。 So to fix the error you need to provide the correct url to connect.因此,要修复错误,您需要提供正确的 url 进行连接。

To get a mongodb instance you can host your own mongodb server or use online mongodb service such as mongodb official service Atlas .要获得 mongodb 实例,您可以托管自己的 mongodb 服务器或使用在线 mongodb 服务,例如 mongodb 官方服务图集

Previously, there is exist an add-on for mongodb mLab on heroku that you can use but it seem that it's has been discontinued.以前,您可以使用 heroku 上的 mongodb mLab的附加组件,但似乎已停产。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM