Cannot connect to daemon

started mongod:
“vagrant@m103:~$” mongod --port 27000 --bind_ip “local host, 192.168.103.100”
2019-12-06T23:23:20.106+0000 I CONTROL [initandlisten] MongoDB starting : pid=2110 port=27000 dbpath=/data/db 64-bit host=m103

and the return ends with:
2019-12-06T23:23:21.716+0000 I NETWORK [initandlisten] listening via socket bound to 192.168.103.100
2019-12-06T23:23:21.716+0000 I NETWORK [initandlisten] listening via socket bound to /tmp/mongodb-27000.sock
2019-12-06T23:23:21.716+0000 I NETWORK [initandlisten] waiting for connections on port 27000

then in 2nd shell:
“vagrant@m103:~$” mongo --port 27000
MongoDB shell version v3.6.16
connecting to: mongodb://127.0.0.1:27000/?gssapiServiceName=mongodb
2019-12-06T23:31:06.178+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27000, in(checking socket for error after poll), reason: Connection refused
2019-12-06T23:31:06.179+0000 E QUERY [thread1] Error: couldn’t connect to server 127.0.0.1:27000, connection attempt failed :
connect@src/mongo/shell/mongo.js:263:13
@(connect):1:6
exception: connect failed

again in 2nd shell:
“vagrant@m103:~$” validate_lab_first_application_user

Client experienced a timeout when connecting to the database - check that mongod
is running on the correct port, and that the ‘m103-application-user’ user
authenticates against the admin database.
vagrant@m103:~$ mongo --port 27000
MongoDB shell version v3.6.16
connecting to: mongodb://127.0.0.1:27000/?gssapiServiceName=mongodb
2019-12-06T23:37:38.634+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27000, in(checking socket for error after poll), reason: Connection refused
2019-12-06T23:37:38.635+0000 E QUERY [thread1] Error: couldn’t connect to server 127.0.0.1:27000, connection attempt failed :
connect@src/mongo/shell/mongo.js:263:13
@(connect):1:6
exception: connect failed

I don’t understand how to resolve this scenario

again at the 2nd shell:
“vagrant@m103:~$” ps -ef | grep mongod
vagrant 2110 1960 1 23:23 pts/0 00:00:17 mongod --port 27000 --bind_ip local host, 192.168.103.100
vagrant 2387 2227 0 23:52 pts/2 00:00:00 grep --color=auto mongod

1 Like

It should have been localhost instead of local host. And there should be no space after the comma --> “localhost,192.168.103.100”

Due to the problem aforementioned, it connected to 192 instead of localhost. So if you want to make a connection as it is, you need to specify the 192 IP as the host. Otherwise, restart your mongod with the fix and you should be fine without specifying a host.

1 Like

much thanks…it’s strange that the test is asking us to do things that are not covered in the course…there’s no discussion of bindIP in the video (or auth) …so the precise syntax is a bit of a guessing game… appreciate the help

You’re welcome!

In this particular instance, they were all discussed in prior lectures. It would be beneficial for you to go through all the videos again:


no - the screen shot you show of Command Line Option - - in the current video for this course they only discuss:
–port
–dbpath
–logpath
–fork

the video is entitled m103 The Mondod and is 6:00 length…following this then is a test asking for IPbind and Auth but those are not discussed at all…


You’re doing the Launching Mongod lab. The video just before the lab (Configuration File) discusses those command line options.

What I’m hinting at is that before you do any lab, make sure you watch all the videos prior to the lab.

no - that is not the order of my course content. Lab Launching mongod is before Lecture Configuration File

and the quiz requires bind and auth and so am not yet successful in: validate_lab_launch_mongod
and therefore I don’t think I can skip the quiz to advance further…

I need to take a screen shot to prove this to you I guess…

No it’s fine. They’ve moved things around.

You did well to discover the other options. :+1:

unfortunately I’ve spent a lot of time and still get this message at: validate_lab_launch_mongod:

Client experienced a timeout when connecting to the database - check that mongod is running on the correct port, and that your user was created with the correct settings.

I feel somewhat burdened by an unfair process at the moment…not seek an answer to a test but understanding as to how this is suppose to work…

I believe it comes down to bringing up the daemon correctly; and using this:
mongod --auth --port 27000 --bind_ip “localhost,192.168.103.100”

I believe dbpath is a default and not needing to be specified but am guessing about authorization…

The error message is in two parts. The first one suggests making sure that the process is running, and the second one is about auth, username/password and the localhost exception.

For the first part, the ps command in your original post shows running processes. Let’s see the output.

“vagrant@m103:~$” ps -ef | grep mongod
vagrant 2401 2384 1 17:41 pts/0 00:00:19 mongod --auth --port 27000 --bind_ip localhost,192.168.103.100
vagrant 2786 2616 0 18:14 pts/2 00:00:00 grep --color=auto mongod

am thinking I set up authorization wrong but still guessing on that point as no instruction on how to check this point…

There’s one requirement that you haven’t met:

If you can’t login using the mongo command I saw earlier, then your assumption is correct. Before we discuss how to fix it, did you definitely create the user? As a test, try and login with:
mongo --port 27000

mongo --port 27000 brings the MongoDB Enterprise > prompt

in the video /data/db/ is default so I didn’t think it needed to be specified.

the notes after the video but before the quiz are to do:

mongo admin --host localhost:27000 --eval ’
db.createUser({
user: “m103-admin”,
pwd: “m103-pass”,
roles: [
{role: “root”, db: “admin”}
]
})

…and so I did do that…

realize now that: db.shutdownServer()
is not working “no users authorized”

can kill the pid though to restart things

To authenticate a user, use the following (substituting username and password with the correct credentials):
use admin
db.auth("username", "password")

The return value must be 1. If it’s not 1 then it failed to authenticate.

Then try and shutdown the server (making sure you’re using the admin db):
use admin
db.shutdownServer()

If you’re not successful, then suggest you do the following:

  1. Kill the current mongod process:
  2. Delete the db sub directory and re-create it
  3. Run mongod by specifying all the options including the db path

007 - I really appreciate your patience in sticking with this.

from data dir
mkdir db

launched daemon with:
“vagrant@m103:~$” mongod --port 27000 – HAVE EDITED THIS PART OUT AS PART OF QUIZ - ASK A QUESTION IF UNCLEAR BUT THE REMAINDER OF THIS DIALOG MAY HELP…

2nd shell
use admin
db.auth(“m103-admin”, “m103-pass”)
returned 1

2nd shell
“vagrant@m103:~$” validate_lab_launch_mongod
returns: You need to specify db path /data/db.

2nd shell
“vagrant@m103:~$” ps -ef | grep mongod
vagrant 4123 4092 1 01:25 pts/0 00:00:15 mongod --port 27000 --bind_ip localhost,192.168.103.100 --dbpath data/db --auth
vagrant 4430 4219 0 01:49 pts/2 00:00:00 grep --color=auto mongod

If I interpret the error statement correctly, I do not understand the syntax of db path in the mongod launch - the example in the video is for a logpath and thought that same syntax would work…in my notes I don’t have “” symbols for the path…

The screenshot in my second post shows an example of db path usage.

So you once again, you need to cleanup as per my last post and restart mongod to include the db path option.

By the way, please also remember to edit all your posts that contain elements of answers to the lab.

greetings, I have added the / symbol to be /data/db in the mongod launch. (for other students: in the video lecture when defining the logpath that there is no / symbol used and no example of defining the dbpath…thus the confusion).

now the lab launch validate returns a time out

today the db.auth is returning 0 which has caught me off guard
it would seem the user that was applied yesterday (my post 19 hrs past) didn’t seem to stick after reboot…yesterday the return of db.auth was 1… one wouldn’t think a user needs to be defined after every boot but I’m still learning and would welcome advice on this point…perhaps I did not create the user correctly…

I note your comment on editing to not reveal answers to quiz - I definitely do not wish to violate terms however at the moment it would make our string difficult to review - and since we’re discussing syntax which was not taught in the video seems like it could be more helpful than hurtful for other strugglers like me - - but let me know if this view is a problem…

This is actually not a MongoDB feature. It’s Linux style of writing file/directory paths. One thing the course fails to highlight is that students will need to brush up on some basic Linux commands.

Most likely. You probably forgot to switch to the admin db before creating the user or you entered the wrong username/password during or after creation. As usual, clean up and redo the mongod.

Rules are rules, I don’t make the rules :slight_smile: I would suggest sticking to the rules. In my view, the solution will be etched into a student’s memory if he/she has to go through the difficult path to finding that solution.