0

I have mongodb installed on my pi successfully for a few months. Since yesterday, I've not been able to connect to it from the local machine, but bizarrely I can connect to it from another machine on the same network.

If I connect locally, I get this

MongoDB shell version: 2.1.1-pre-
Sat Sep  3 17:20:39 versionCmpTest passed
Sat Sep  3 17:20:39 versionArrayTest passed
connecting to: test
Sat Sep  3 17:20:39 creating new connection to:127.0.0.1:27017
Sat Sep  3 17:20:39 BackgroundJob starting: ConnectBG
Sat Sep  3 17:22:47 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
Sat Sep  3 17:22:47 User Assertion: 12513:connect failed
exception: connect failed

Whereas remotely, it works fine

MongoDB shell version: 3.2.9
connecting to: 192.168.1.6:27017/test
2016-09-03T18:43:20.705+0100 D NETWORK  [thread1] creating new connection to:192.168.1.6:27017
2016-09-03T18:43:20.705+0100 D COMMAND  [ConnectBG] BackgroundJob starting: ConnectBG
2016-09-03T18:43:20.709+0100 D NETWORK  [thread1] connected to server 192.168.1.6:27017 (192.168.1.6)
2016-09-03T18:43:20.717+0100 D NETWORK  [thread1] connected connection!
Server has startup warnings: 
Sat Sep  3 17:16:46 [initandlisten] 
Sat Sep  3 17:16:46 [initandlisten] ** NOTE: This is a development version (2.1.1-pre-) of MongoDB.
Sat Sep  3 17:16:46 [initandlisten] **       Not recommended for production.
Sat Sep  3 17:16:46 [initandlisten] 
Sat Sep  3 17:16:46 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Sat Sep  3 17:16:46 [initandlisten] **       see http://blog.mongodb.org/post/137788967/32-bit-limitations
Sat Sep  3 17:16:46 [initandlisten] **       with --journal, the limit is lower
Sat Sep  3 17:16:46 [initandlisten] 

I've been tearing my hair out for the last few hours trying to get it to work.

FWIW the only other change I've made to the box is I've installed a wifi dongle a few days ago, but mongo was working fine with it until yesterday

  • It looks like mongo is listening on 192.168.1.6, but not 127.0.0.1. Run a "netstat -anp" to see what IP addresses (and ports) mongo is listening on. 0.0.0.0 would be shown to mean all IP addresses the device has. – awatts Sep 3 '16 at 20:58
0

Turns out the problem wasn't anything to do with mongo. Pinging localhost and 127.0.0.1 were not completing successfully

I had edited the /etc/network/interfaces file and, for some reason, removed the entry for lo

so, adding back in the lines below and rebooting solved the problem

auto lo
iface lo inet loopback

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.