简体   繁体   English

MongoError:首次连接时无法连接到服务器localhost:27017

[英]Mongoerror: failed to connect to server localhost:27017 on first connect

I have created an application using MEAN, After that, I have created the ec2 Linux instance, where I am running this application.I have installed all the dependencies. 我使用MEAN创建了一个应用程序,然后创建了运行该应用程序的ec2 Linux实例。我已经安装了所有依赖项。

Added port 27017 on security group page. 在安全组页面上添加了端口27017。 running the command on the ec2 instance as node server.js 在ec2实例上作为node server.js运行命令

Node: My mongo DB is outside my cloud instance ie on my laptop. 节点:我的mongo数据库在我的云实例之外,即在我的笔记本电脑上。

How can I fix this error? 如何解决此错误?

You need to open your laptop to internet which is almost impossible (and you shouldn't). 您需要打开笔记本电脑才能上网(几乎不应该这样做)。 That means you need a MongoDB server which is accessible by your EC2 Linux instance. 这意味着您需要一个可由EC2 Linux实例访问的MongoDB服务器

You may use a free mongodb hosting such as mlab 您可以使用免费的mongodb托管,例如mlab

On the other hand you can enable another EC2 instance and setup your own mongodb. 另一方面,您可以启用另一个EC2实例并设置自己的mongodb。 Beware that you may need to setup firewall if it's not an internal network. 请注意,如果它不是内部网络,则可能需要设置防火墙。

暂无
暂无

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

相关问题 MongoError:首次连接时无法连接到服务器[localhost:27017](ECONNREFUSED) - MongoError: failed to connect to server [localhost:27017] on first connect (ECONNREFUSED) MongoError:无法连接到服务器[localhost:27017] - MongoError: failed to connect to server [localhost:27017] MongoError:无法连接到服务器[localhost:27017] - MongoError: failed to connect to server [localhost:27017] 连接到MongoDB时出错= MongoError:首次连接时无法连接到服务器[localhost:27017] - Error when connecting to MongoDB = MongoError: failed to connect to server [localhost:27017] on first connect 故障 - MongoError:无法连接到服务器 [未定义:27017] - Glitch - MongoError: failed to connect to server [undefined:27017] MongoNetworkError:首次连接时无法连接到服务器[localhost:27017] - MongoNetworkError: failed to connect to server [localhost:27017] on first connect UnhandledPromiseRejectionWarning: MongoNetworkError: 在第一次连接时无法连接到服务器 [localhost:27017] [MongoNetworkError] - UnhandledPromiseRejectionWarning: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError Node.js连接到MongoDB会引发错误:MongoError:首次连接时无法连接到服务器[127.0.0.1:27017] - Node.js connect to MongoDB throw an error :MongoError: failed to connect to server [127.0.0.1:27017] on first connect MongoDB 与 Docker “首次连接时无法连接到服务器 [localhost:27017]” - MongoDB on with Docker "failed to connect to server [localhost:27017] on first connect " node.js-错误:首次连接时无法连接到服务器[localhost:27017] [MongoNetworkError:连接ECONNREFUSED 127.0.0.1:27017] - node.js - Error: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connect ECONNREFUSED 127.0.0.1:27017]
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM