I tried to restore mongo from dump but failed:
mongorestore --port 27133 dump
2015-05-07T09:39:11.760+0300 Failed: no reachable servers
I had difficulty with that question also.
mongorestore --host f8cab83e7294 --port 27601 gene_backup_final/gene_backup/s2/ --verbose
2016-12-05T13:48:15.333-0700 Failed: error connecting to db server: no reachable servers
I failed to initiate the replica set. That is why there was no reachable server
After initiating the RS, restore worked.
mongo localhost:27501
rs.initiate()
try adding host param
mongorestore --host=127.0.0.1 --port=27133 dump
I have MongoDB installed through Homebrew, and was having this issue. Here are the symptoms:
These failed:
mongorestore dump
mongorestore dump --host=localhost
The error I got: Failed: error connecting to db server: no reachable servers
These worked (as a workaround):
mongorestore dump --host=127.0.0.1
mongorestore dump --host=0.0.0.0
This fixed the problem for me:
brew update && brew upgrade
That updated MongoDB to 3.0.7 and now mongorestore dump
works without the host flag.
In my case, I am defining port two times.
mongorestore --noIndexRestore --host X.X.X.X:27017 -d XYZ --port 27017 foldername
Solve in my case,
mongorestore --noIndexRestore --host X.X.X.X -d XYZ --port 27017 foldername
check your mongod configuration file, if you have enabled replication disable it, if enabled, key based authentication disable it basically disable every other thing and restart the mongod service and then try doing mongo restore.
And BTW, try binding mongod ipaddress to your machine address as well, if it is a local mongod instance try binding the ip address to 0.0.0.0, in mongod.conf file under bind_ip="your ip address", do let me know it does or does not.
Do you run mongo in replica set, i.e., mongod --replSet rs0
?
If yes, please remember to run in your mongo shell the command: rs.initiate()
Then you can use cmd mongorestore
to restore your db.