title: MongoDB: How to properly export a collection from MongoDB to my computer?
body: <p>Given the following database and related collection <strong>scows.tasks</strong>, how do I export 2GB it for storage purposes so to make space? </p>
  
  <p><img src="https://i.imgur.com/f9Mkns9.png" alt="storage"></p>
  
  <p>I have been trying to do it using various ways but none of them worked:</p>
  
  <pre><code>mongoexport --verbose --db scows --collection tasks --out tasks.json --verbose
  
  mongoexport -vvvv --db scows --username='my_username' --password='my_passwd' --collection tasks --out /home/to/Desktop/storageMongo/tasks.json -f 'my_passwd'
  
  mongoexport --host=127.0.0.1 --db scows --collection tasks --out tasts.json
  </code></pre>
  
  <p>And in doing this I always got the same exact error:</p>
  
  <blockquote>
    <p>2020-02-13T12:55:17.183-0500  will listen for SIGTERM, SIGINT, and
    SIGKILL 2020-02-13T12:55:20.690-0500  error connecting to db server: no
    reachable servers</p>
  </blockquote>
  
  <p><strong>Posts I used to solve the problem</strong> but that unfortunately didn't help me out:</p>
  
  <p>1) <a href="https://stackoverflow.com/questions/57594702/syntax-missing-before-statement-in-mongoexport">I used this one</a> but nothing happened </p>
  
  <p>2) <a href="https://stackoverflow.com/questions/17041337/mongodb-mongorestore-command-not-found/36544032">This</a> also but same results as above</p>
  
  <p>3) <a href="https://www.tothenew.com/blog/export-very-large-data-from-a-mongodb-collection-using-script/" rel="nofollow noreferrer">This source</a> was useful but didn't help me find out the problem</p>
  
  <p>4) <a href="https://www.systutorials.com/docs/linux/man/1-mongoexport/" rel="nofollow noreferrer">And lastly this one</a> to help me with the command but I always had the same error.</p>
  
  <p>5) Also as mentioned in the official documentation I am using my <code>Ubuntu 18.04</code> shell as terminal to input the command instead of the <code>mongo</code> shell.</p>
  
  <p>How do I properly export a collection from MongoDB to my computer?</p>