Can't connect to the localhost

Hello,

I’m in the “Chapter 1: Authentication” in the “Homework 1.1 : Enable SCRAM-SHA-1” exercise trying to make vagrant work.

After execute “vagrant ssh database” and have access to the same I tried to do a little test doing “mongo”, but it returned:

MongoDB shell version: 3.2.21
connecting to: test
2018-10-18T21:08:58.843+0000 W NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
2018-10-18T21:08:58.844+0000 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:229:14
@(connect):1:6

exception: connect failed

Any idea why?

Thanks in advance

I have the same issue, let’s hope someone could help us.

Hi Jorge_18974,

Those messages likely indicate there isn’t a mongod server running on the database server at least not on port 27017.

Did you configure and start a mongod single server or mongod cluster ?

The database VM is provisioned with MongoDB software but doesn’t come with configure / deployed mongod instances - that is what you’ll be doing in the assignments !

You need to be familiar with the basic/common options for bringing up a mongod server as well as replica sets. In this course will be discussing options and commands on the topics of security.

Hope that helps

David

I was running mongod but I didn’t notice the “exception in initAndListen: 29 Data directory /data/db not found., terminating” error before. This fix it.

1 Like

Thank you everyone!! It helped me a lot!

Use this command sudo mongod --dbpath=/var/lib/mongodb --auth. If you get the below error
exception in initAndListen: 29 Data directory /data/db not found., terminating.
This solved the problem.