Not connecting with mongod from command line

Hello people!
I’m having trouble starting an instance of mongod, from the command line. I have used the knowledge acquired in previous classes but it still does not work. Can someone explain to me how I do this?

Just type mongod and if this does not work please provide the error messages.

exception in initAndListen: 29 Data directory /data/db not found., terminating

The message Data directory /data/db not found means that mongod cannot find the directory /data/db. You have to create it.

I created it, but it still does not run

Error message please.

it’s not exactly a mistake:
Initializing full-time diagnostic data capture with directory ‘/data/db/diagnostic.data’
2019-02-18T15:01:49.235+0000 I NETWORK [initandlisten] waiting for connections on port 27017

I don’t understand. You write:

yet you show that it is working:

But I can not do anything

Not even connect with mongo

You have to let mongod running when you try to connect with mongo shell.

even so the mongo does not run

If you get

then mongod is running and waiting for mongo shell connections as indicated by waiting for connections on port 27017.

When you get SocketException starting mongo shell it means mongod is not running anymore. That’s why I wrote:

Problem has been resolved. The mongod service was no longer working. All I did was restart the service. But there was another problem.
When I run the validate_lab_launch_mongod command this problem appears:
[js] ReferenceError: validate_lab_launch_mongod is not defined:
@ (shell): 1: 1.

How can I solve it?

Shouldn’t it be run from the vagrant shell prompt, not the mongo shell?

2 Likes

Exactly. Joao, simply run the command from the vagrant shell.