Mongodb无法连接到本地主机

Mongodb无法连接到本地主机

本文介绍了Mongodb无法连接到本地主机,但可以连接到本地主机的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我尝试仅使用mongo命令运行mongodb shell,我将得到:

If I try to run mongodb shell with the mongo command alone, I get:

Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84

例外:连接失败

但是,如果我这样规定本地主机的LAN IP地址:

However, if I stipulate localhost's LAN IP address like this:

mongo 10.10.5.90

...连接正常.

任何线索?

推荐答案

mongodb.conf(或启动脚本)中是否设置了bind_ip? 为清楚起见进行编辑设置将IP地址限制为仅侦听该IP地址.

Do you have a bind_ip set in your mongodb.conf (or startup script)? edit for clarity A bind_ip setting limits the IP it will listen on to that IP only.

请参阅"IP地址绑定"部分: http://www.mongodb.org /display/DOCS/Security + and + Authentication

See the IP Address Binding section: http://www.mongodb.org/display/DOCS/Security+and+Authentication

如果没有,您是否有任何防火墙规则阻止localhost访问?那有点奇怪,但是我想不出另一个原因,尽管LAN IP可以工作,但是它却无法工作.

If not, do you have any firewall rules blocking the localhost access? That would be kind of strange, but I can't think of another reason why it wouldn't work while the LAN IP would work.

这篇关于Mongodb无法连接到本地主机,但可以连接到本地主机的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 23:29