如何在AWS ec2或Elastic Beanstalk上使用MongoDb部署我的Node.js应用程序?

时间:2016-12-23 08:01:17

标签: node.js mongodb amazon-web-services amazon-ec2 elastic-beanstalk

在为ec2尝试AWS CodeDeploy服务时,我得到了(错误代码:HEALTH_CONSTRAINTS)。使用Elestic Beanstalk时出现Denay Status错误。

In Elastic Beanstalk logs node.js log showing error MongoError: failed to connect to server [localhost:27017] on first connect
    at Pool.<anonymous> (/var/app/current/node_modules/mongodb-core/lib/topologies/server.js:313:35)
    at emitOne (events.js:96:13)
    at Pool.emit (events.js:188:7)
    at Connection.<anonymous> (/var/app/current/node_modules/mongodb-core/lib/connection/pool.js:271:12)
    at Connection.g (events.js:291:16)
    at emitTwo (events.js:106:13)
    at Connection.emit (events.js:191:7)
    at Socket.<anonymous> (/var/app/current/node_modules/mongodb-core/lib/connection/connection.js:165:49)
    at Socket.g (events.js:291:16)
    at emitOne (events.js:96:13)
    at Socket.emit (events.js:188:7)
    at emitErrorNT (net.js:1276:8)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickCallback (internal/process/next_tick.js:98:9)
Server listening on port 8081.

1 个答案:

答案 0 :(得分:0)

我找到了替代解决方案。我从AWS Marketplace创建了一个ec2实例(由Bitnami提供平均值)。然后按照本教程https://scotch.io/tutorials/deploying-a-mean-app-to-amazon-ec2-part-1

进行操作