Error connecting to db server: no reachable servers

I am trying to follow along the video " Response Time Degredation, Part 2" and when I try to import data get the following error. I have all the necessary files in the dataset folder.

vagrant@m312:~$ mongoimport -d m312 -c norberto_friends /dataset/friends_10.json
2019-04-18T05:04:22.059+0000 […] m312.norberto_friends 0B/1.57KB (0.0%)
2019-04-18T05:04:22.576+0000 […] m312.norberto_friends 0B/1.57KB (0.0%)
2019-04-18T05:04:22.578+0000 Failed: error connecting to db server: no reachable servers
2019-04-18T05:04:22.578+0000 imported 0 documents

The error ‘no reachable servers’ means that mongod is not running at the host and port you are specifying. Since you do not specify and host and port mongo tries to connect to the default host, which is localhost, and default port which is 27001.

The solution is to start mongod or to specify a host and port where mongod is running.

I tried starting the mongod process on port 27001 and get the following error

You do not have permission to write on this directory.

  1. mkdir --parents /home/vagrant/data/db
  2. start mongod with --dbpath /home/vagrant/data/db
  3. you do not need to specify 27001 because it is the default port

I have concerns about the fact you are having this kind of issues in M312. This is an advanced course and basic stuff like starting a mongod instance should have be mastered already.

Does not matter whether it’s basic or advanced when you start getting such errors sometimes you get lost. I did not had any issues until I started working on chapter 3 and suddenly started having this issues. You provide a virtual machine and I assume it has all necessary permissions and I have used vagrant in courses before and have not set any permissions to /data/db then why in this course does somebody think that there would be permission issues.

I am just following the steps from the video lecture and see that the statement vagrant@m312:~$ mongorestore -d m312 -c norberto_friends /dataset/friends_10.json does not work when I tried to execute on the vagrant environment provided, but it is shown as working in the video lesson. I google’d and found out that the args -d and -c should be used for .bson files and --db and --collection should be used for .json files and believe me I have not seen in any of the courses that I did on mongodb university that this has been mentioned.

Even though this is advanced course the basic thing does not work when I follow along the video. Just wanted to bring to your notice that even though you have mastered or have done other courses always there is a learning curve . Also not sure when these videos were recorded. Please add some lecture notes wherever necessary !

I was able to import successfully,when i used the following statement
vagrant@m312:~$ mongoimport --db m312 --collection norberto_friends --file /dataset/friends_10.json
2019-04-18T16:15:58.298+0000 connected to: localhost
2019-04-18T16:15:58.339+0000 imported 10
documentsmongoimport%20json%20files|690x91 mongoimport%20json%20files|690x91


Just to clarify, you are entirely incorrect that the -d and -c parameters are for .bson files and that --db and --collection are for .json. They are simply variants of the same parameter. It might be well for you to refer to the actual MongoDB documentation here rather than try to use a Google search when you seem to be pretty confused. Not everything you find on Google is correct, and you need some background to sort out the actual answers from the junk.