连接被拒绝到 MongoDB errno 111 [英] Connection refused to MongoDB errno 111

查看:42
本文介绍了连接被拒绝到 MongoDB errno 111的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台运行 Ubuntu 12.04 LTS 和 MongoDB 实例的 Linode 服务器(服务正在运行并且可以在本地连接),但我无法从外部源连接到该服务器.

I have a Linode server running Ubuntu 12.04 LTS and MongoDB instance (service is running and CAN connect locally) that I can't connect to from an outside source.

我已将这两条规则添加到我的 IP 表中,其中 <ip 地址 > 是我想要连接的服务器(如这个 MongoDB 参考):

I have added these two rules to my IP tables, where < ip address > is the server I want to connect FROM (as outlined in this MongoDB reference):

iptables -A INPUT -s -p tcp --destination-port 27017 -m state --state NEW,ESTABLISHED -j ACCEPT

iptables -A OUTPUT -d -p tcp --source-port 27017 -m state --state ESTABLISHED -j ACCEPT

而且我在我的 IP 表中看到了允许在 27017 上与 < 之间的连接的规则.ip 地址 > 但是当我尝试从 , < 连接时ip 地址 > 使用这样的命令到我的 mongo 数据库:

And I see the rule in my IP table allowing connections on 27017 to and from < ip address > however when I try to connect from , < ip address > to my mongo database using a command like this:

mongo 数据库域/数据库名 -u 用户名 -p 密码

我收到此错误:

2014-07-22T23:54:03.093+0000 警告:无法连接到数据库服务器ip:27017,原因:errno:111 连接被拒绝2014-07-22T23:54:03.094+0000 错误:无法连接到服务器 :27017 (databaseserverip),在 src/mongo/shell/mongo.js:148 连接尝试失败异常:连接失败

非常感谢任何帮助!!!!谢谢!!!

Any help is VERY APPRECIATED!!!! Thanks!!!

推荐答案

感谢大家的帮助!

原来是iptable冲突.列出端口打开的两个规则(导致端口关闭).

Turns out that it was an iptable conflict. Two rules listing the port open (which resulted in a closed port).

然而,aka 的一个评论和 manu2013 的另一个评论是我会遇到的问题,如果不是因为冲突.

However, one of the comments by aka and another by manu2013 were problems that I would have run into, if not for the conflict.

所以!永远记住编辑 /etc/mongod.conf 文件并设置你的 bind_ip = 0.0.0.0 以便在外部建立连接.

So! Always remember to edit the /etc/mongod.conf file and set your bind_ip = 0.0.0.0 in order to make connections externally.

此外,请确保您的 iptable 中没有与 mongo 想要的端口冲突的规则(请参阅 mongodb 网站上的链接 以正确设置您的 iptables.

Also, make sure that you don't have conflicting rules in your iptable for the port mongo wants (see link on mongodb's site to set up your iptables properly).

这篇关于连接被拒绝到 MongoDB errno 111的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆