Reputation: 21
It may be a very simple/obvious answer but I've tried running the following variations of the same command to backup a local mongo database and they all fail by returning:
Failed: error connecting to db server: no reachable servers
These are the commands:
mongodump --host localhost --port 27017 --db mydbname --collection mycollection
mongodump -h localhost:27017 --db mydbname --collection mycollection -u user -p passw --out <folder path>
mongodump -h localhost:27017 --db mydbname --collection mycollection --out <folder path>
mongodump --port 27017 --db mydbname --collection mycollection --out <folder path>
mongod instance was running on a separate terminal window while I tried them all
I JOURNAL [initandlisten] journal dir=/data/db/journal I JOURNAL [initandlisten] recover : no journal files present, no recovery needed I JOURNAL [durability] Durability thread started I CONTROL [initandlisten] MongoDB starting : pid=88451 port=27017 dbpath=/data/db 64-bit host=Diegos-MBP.home I CONTROL [initandlisten] I CONTROL [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000 I JOURNAL [journal writer] Journal writer thread started I CONTROL [initandlisten] db version v3.0.6 I CONTROL [initandlisten] git version: nogitversion I CONTROL [initandlisten] build info: Darwin yosemitevm.local 14.5.0 Darwin Kernel Version 14.5.0: Wed Jul 29 02:26:53 PDT 2015; root:xnu-2782.40.9~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49 I CONTROL [initandlisten] allocator: system I CONTROL [initandlisten] options: {} I NETWORK [initandlisten] waiting for connections on port 27017 I NETWORK [initandlisten] connection accepted from 127.0.0.1:55910 #1 (1 connection now open)
I cannot find mongodb.conf in /etc/mongod.conf
. I installed mongo with homebrew. Maybe it is related to an authentication issue?
Upvotes: 2
Views: 5608
Reputation: 106
I just ran into the same issue and it appears that using 127.0.0.1 instead of localhost in the host setting worked...
Like :
mongodump -h 127.0.0.1:27017 -d demo
If you are using a replicat set (like "myset"), use this instead :
mongodump -h myset/127.0.0.1:27017 -d demo
Hope this helps...
Upvotes: 4