Stuck on first lab Launching Mongod

Trying to validate but always getting
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.

using this to start the daemon mongod --port 27000 --dbpath data/db/ --auth --bind_ip 127.0.0.1,192.168.103.100

the copy/paste the user creation from the lesson and the running the validation only for it to give me the error message, what am I missing?

Hey @Alexandru_47292

Some suggestions as I am not sure of what you are missing:

  1. Run ps -ef | grep mongod to see if your mongod is indeed running
  2. Are you in the Vargant environment VM?
  3. When you signed into the mongo shell to create the user did you use the admin db?
1 Like

Hi natac, thanks for the quick reply.

I didn’t signed into the shell to create the user, following the lab intro just say this

Use the following command to connect to the Mongo shell and create the following user. You will need this user in order to validate subsequent labs.

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

this is the ps output
vagrant@m103:~$ ps -ef | grep mongod
vagrant 3129 2175 0 19:33 pts/0 00:00:03 mongod --port 27000 --dbpath data/db/ --auth --bind_ip 127.0.0.1,192.168.103.100
vagrant 3195 2306 0 19:39 pts/1 00:00:00 grep --color=auto mongod

and yes, I’m in the VM shell

Just going to add…

Here’s one issue… this path doesn’t meet the requirements.

Are you sure you’re working on the first lab Launching Mongod? If you are, I believe that you’re running the wrong validation. The “m103-application-user” is related to the Creating First Application User lab.

1 Like

Hi 007,

yep I’ve noticed it’s on the root not in the home folder! Thanks.

Now I can’t create the user.
If I run it in bash I get this from mongod
2020-02-16T19:54:57.449+0000 I ACCESS [conn4] Unauthorized: not authorized on admin to execute command { endSessions: [ { id: UUID(“eace5788-8480-4e5f-bf0a-26df7e8b54dd”) } ], $db: “admin” }

and if I mongo --port 27000; use admin; and try to create the user
2020-02-16T19:54:10.089+0000 E QUERY [thread1] Error: couldn’t add user: there are no users authenticated :

I’m really lost! The explanations in the lessons dropped a lot from the m001, not sure how to proceed

Using the localhost exception, you can only create the first user once. So it is possible that you have already created that first user… try to login.

1 Like

Started from scratch, works now but not sure why.

started with auth and same error, Unauthorized.

Then I’ve started mongod without auth the first time, created the user and then started it with auth…

not sure if that’s why it wasn’t working, really missing some info

:hot_face:

thanks all for the time

You don’t need to do this.

Here are the steps with auth:

  1. Start mongod with auth
  2. Connect using localhost:
    --host localhost:27000
  3. Use the admin db. Make sure you’re on the admin db.
  4. Create the first user

Now you can either:

  • Authenticate whilst still connected:
    use admin
    db.auth("username", "password")

Or

  • Log out and log back in with the new user (making sure you’re authenticating against the admin db). Here’s one of many ways:
    mongo --host <hostname>:<port> -u <username> -p <password> --authenticationDatabase admin
3 Likes

Thanks @007_jb and @natac13 .

Hi @Alexandru_47292,

I just wanted to point out one thing here :

@007_jb has already mentioned in the post #4 that you are talking about two different labs here. One key point to keep in mind here is that each lab in M103 has different requirements and hence you must run the correct validation script to validate the labs.

Thanks,
Shubham Ranjan
Curriculum Services Engineer

1 Like