mongorestore failure: error writing file "/var/lib/mongodb" I want sync my server db with my local db;


dump db


  mongodump --db [db name]

copy dump folder into my local
restore dump on my local


  mongorestore --db [db name] [dump folder path]



I have 4 dbs I can do this successfully for 3 of them but I got 

mongorestore error: failure writing file /var/lib/mongodb


when I restore 4th db

There is enough room on the file system. I restarted the server and repeated the process and I don't get this error anymore. However, sometimes I get:

failed: restore error: cohortV5.orders: 
error restoring from dump/cohortV5/orders.bson: insertion error: EOF


and sometimes I get: 

Failed: restore error: cohortV5.orders: error creating indexes for cohortV5.orders: 
createIndex error: no reachable servers
Finally after two days, I found the answer, I get this error because of lack of memory. You need to add more memory if you work with big collection.