【发布时间】:2020-01-09 20:37:23
【问题描述】:
我正在尝试连接 mongodb,但它给了我错误。
MongoDB shell 版本:3.2.22 连接到:test 2019-09-07T05:17:09.460+0000 W 网络 [thread1] 无法连接到 127.0.0.1:27017,在(轮询后检查套接字是否有错误),原因:errno:111 连接被拒绝 2019-09-07T05:17:09.461+0000 E QUERY
[thread1] 错误:无法连接到服务器 127.0.0.1:27017, 连接尝试失败:connect@src/mongo/shell/mongo.js:229:14 @(connect):1:6
试过了:
sudo nano /etc/mongod.conf
- 评论绑定
#network interfaces
net:
port : 2701
#bindip = [0.0.0.0]
- 将此设置为
#network interfaces
net:
port : 2701
bindip : 0.0.0.0
- 将此设置为
#network interfaces
net:
port : 2701
bind_ip = 0.0.0.0
- 将此设置为
#network interfaces
net:
port : 2701
bindip = [0.0.0.0]
然后保存此文件:
sudo service mongod restart mongo
再次连接被拒绝给出同样的错误:
MongoDB shell 版本:3.2.22 连接到:test 2019-09-07T05:17:09.460+0000 W 网络 [thread1] 无法连接到 127.0.0.1:27017,在(轮询后检查套接字是否有错误),原因:errno:111 连接被拒绝 2019-09-07T05:17:09.461+0000 E QUERY
[thread1] 错误:无法连接到服务器 127.0.0.1:27017, 连接尝试失败:connect@src/mongo/shell/mongo.js:229:14 @(connect):1:6
有什么帮助吗?
【问题讨论】:
-
只是好奇,您设置的端口是 2701,但您在端口 27017 上遇到错误。无法连接到 127.0.0.1:27017
-
@Pacifist_AWS 只是拼写错误 :( 还有 27017
-
您的日志显示“无法连接到 127.0.0.1”,您是否尝试从 ec2 实例中连接?还是在 ec2 实例之外?
-
ec2 实例中的@RajatGoel
标签: mongodb amazon-ec2 remote-access