Failed to start mongo in second shell

What I do wrong?

Are you running a database at port 27017? By default the program mongo tries to connect to your localhost (127.0.0.1) at MongoDBs default port 27017. If you started your database at a different port, what often is done during the courses, you should try that port. Here is are two examples:

mongod --port 27001

mongod --host "127.0.0.1:27001"

If I absolutely didn’t get the point and named only obvious things, sorry :slight_smile:


But mongod listening the same port, or not?

That’s correct. Your mongo instance actually runs on port 27017. Have you tried, if that port is reachable, e.g. with telnet 127.0.0.1 27017 ? If you can’t reach, maybe something on your system is blocking the connection.

Another point that comes in my mind is the bindIP, but it’s just a bling shot.
ConfigFile: bindIp: 192.168.103.100,localhost
command option: --bind_ip 192.168.103.100,localhost

telnet: Unable to connect to remote host: Connection refused

Maybe something is actually blocking that port. If you don’t have a webserver running, you could try to start the mongod process with port 80 or 8080. Those ports should be not blocked by default. If that’s successful, you know that mongodb works in general on your system, but there some port blocking problems.

Hey @Ivan_59190

I believe the Mongod is running inside the vagrant box.

Therefore when you opened a new shell you need to fisrt run vagrant ssh to get back in the VM look at the terminal headers in your screenshots. Thie first is your local machine the second is from vagrant VM.

If you want to connect to the mongod inside the Vm from outside then you need to run

mongo --host ip-of-vagrant-vm:27017

To connect to the mongo shell from inside the VM just open the new terminal in the M103 folder you made and run

vagrant ssh

then; attempt the connection the the Mongo shell on port 27017

3 Likes

Thank you, yep - vagrant ssh in second shell, I forgot that we are working inside the virtual machine.

Me forgot too, when I was trying to help you :rofl: