I tried to restore mongo from dump but failed:
mongorestore --port 27133 dump
2015-05-07T09:39:11.760+0300 Failed: no reachable servers
First run mongod
If you get exception exception in initAndListen: 29 Data directory /data/db not found., terminating
, do sudo mkdir -p /data/db
If you get expection exception in initAndListen: 98 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
, This probably you have the permission issue. If this is your local, you can run sudo chmod 7777 /data/db
to fix the issue.
Now, mongod
should work.
Then, run mongorestore dump
where your dump file is.
You should successfully restore the dump file.
In my case (with Mongo 3.2.9), the server was configured to listen on the IPv4 localhost
address (127.0.0.1
) but mongorestore
tried only the IPv6 localhost
address (::1
).
Using -h 127.0.0.1
worked. However, this shouldn't be necessary, IMHO, and is a bug in mongorestore
. It should use the same connection logic as the mongo
command-line client, which was working.
Note: replica sets were not enabled.
I have the same problem. I tried to start mongod before restoring my dump, and it work for me. Hope this help this situation
If you're using a hosted service (like MongoDB Atlas), make sure you've set up the IP white-list so that it isn't blocking your IP address. You can set it to 0.0.0.0/0
to whitelist all IP addresses, but this is a bad idea in terms of security so it should only be used as a temporary measure.
I struggled with the same issue while using MongoDB Atlas for a few hours.
I tried to follow the offical guides like Seed with mongorestore and Load File with mongoimport but received the same no reachable servers
error.
I tried to change the command arguments over and over - nothing changed.
But then I navigated inside my cluster to the "Command Line Tools" tab and saw the exact command I should run for mongorestore
, mongodump
, mongoimport
,mongoexport
etc':
Adding as inline the full command:
mongorestore --host
<cluster-name>-shard-0/
<cluster-name>-shard-00-00-obe3i.mongodb.net:27017,
<cluster-name>-shard-00-01-obe3i.mongodb.net:27017,
<cluster-name>-shard-00-02-obe3i.mongodb.net:27017
--ssl
--username <User-Name>
--password <PASSWORD>
--authenticationDatabase admin
The mongorestore
comand can be replaced with mongodump
,mongoimport
,mongoexport
etc'.
(*) Prefer copying the command directly from dashboard because the DNS of the replica-sets might change.
(**) MongoDB shell version v4.2.5.
The problem occured because --replSet
was enabled in configuration. But the node wasn't yet in any replica set.
After I removed --replSet
from configuration, relaunched mongodb server, mongorestore
started to work without any --host
parameter.