【问题标题】:Mongoose - remote database connect failedMongoose - 远程数据库连接失败
【发布时间】:2017-03-20 09:26:23
【问题描述】:

我正在尝试连接到远程服务器中的 mongo 数据库:

$ mongo xxx.xxx.xxx.xx:27017

但我收到此错误:

MongoDB shell 版本:2.6.10 连接到:xxx.xxx.xxx.xx:27017/test 2016-11-07T05:18:39.140+0000 警告:无法连接到 xxx.xxx.xxx.xx:27017,原因:errno:111 连接被拒绝 2016-11-07T05:18:39.142+0000 错误:无法连接到服务器 xxx.xxx.xxx.xx:27017 (xxx.xxx.xxx.xx),连接尝试失败 src/mongo/shell/mongo.js:148 异常:连接失败

有什么想法吗?

我什至尝试使用用户名和密码连接它,但仍然无法连接...

【问题讨论】:

  • 您尝试在哪个环境中运行您的 mongod?
  • 它会显示启动警告但工作正常,例如我可以查询我的数据库和集合。
  • @DavidR 你说的是environment吗?我在 linux ubuntu 上。
  • 你能显示 mongo conf cat /etc/mongod.conf 必须有一行 bind_ip 127.0.0.1,xx.xx.xx.xx 其中 xx.xx.xx.xx 是你的公共 IP
  • 服务器当然是你安装 mongodb 的地方对吧?

标签: node.js mongodb mongoose


【解决方案1】:

运行以下命令:

sudo 服务 mongodb 停止 sudo rm /var/lib/mongodb/mongod.lock sudo 服务 mongod 重启 蒙哥

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-08
    • 2016-01-01
    • 2018-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-08
    相关资源
    最近更新 更多