简体   繁体   中英

Can't connect to MongoD / byzarre

I installed mongoDB through the official tutorial http://www.mongodb.org/display/DOCS/Building+for+Linux

The daemon starts up, a netstat-na | grep 27017 shows:

tcp 0 0 0.0.0.0:27017 0.0.0.0: * LISTEN
unix 2 [ACC] STREAM LISTENING 100949 / tmp/mongodb-27017.sock

I added these iptables rules:

-A INPUT-p tcp-m tcp - dport 27017-j ACCEPT
-A INPUT-p tcp-m tcp - dport 28017-j ACCEPT

When loading through the browser, I get well on the web management interface in 28017

If I add a remote connection on mongoHQ, I get to use the database

By cons, if I run the client locally, an error is raised:

Error: could not connect to server 127.0.0.1 shell / mongo.js: 79 except: connect failed

Same if I try to use the database on an existing project, can't connect to it. I turn around, I do not understand, thank you in advance for your help.

Solution if you have this problem :

iptables -t filter -A OUTPUT -o lo -s 127.0.0.0/8 -d 127.0.0.0/8 -j ACCEPT
iptables -t filter -A INPUT  -i lo -s 127.0.0.0/8 -d 127.0.0.0/8 -j ACCEPT

And it's ok ^^

是否需要在端口27017上明确打开防火墙才能允许出站TCP连接?

iptables -A OUTPUT -p tcp --dport 27017 -j ACCEPT

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM