Mongodb can't connect to localhost but can connect to localhost's IP address

localhost, mongodb

Solution

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.

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

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.

Problem

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 ``` exception: connect failed However, if I stipulate localhost's LAN IP address like this: ``` mongo 10.10.5.90 ``` ...it connects fine. Any clues??

Original source