【发布时间】:2026-01-28 15:05:02
【问题描述】:
我有一个 Ubuntu 14.04 Linux 服务器和 MongoDB 3.2.4 作为 Droplet(一键式应用程序)在 Digital Ocean 上运行。
Ping 服务器正常工作(发布后 droplet 被破坏):
ping 198.199.125.101
我创建了数据库test 和用户:
db.createUser({"user": "test", "pwd": "test", "roles": ["dbOwner"]})
在mongod.conf我改了bindIp: 0.0.0.0并重启了mongoDB
我禁用了防火墙并重新启动了服务器。只是为了测试,只是为了证明 iptables 不是问题(不要在常规服务器上这样做):
sudo ufw disable
问题是我无法远程访问 mongo 数据库
mongo 198.199.125.101:27021/test -u "test" -p "test"
错误信息(连接被拒绝):
MongoDB shell version: 3.2.0
connecting to: 198.199.125.101:27021/test
2016-05-11T22:05:35.876+0200 W NETWORK [thread1] Failed to connect to 198.199.125.101:27021, reason: errno:61 Connection refused
2016-05-11T22:05:35.879+0200 E QUERY [thread1] Error: couldn't connect to server 198.199.125.101:27021, connection attempt failed :
connect@src/mongo/shell/mongo.js:226:14
@(connect):1:6
exception: connect failed
【问题讨论】:
-
bindIp: 198.199.125.101 也一样吗?
-
mongodb端口也是27017
标签: linux mongodb ubuntu remote-access