Errors while validating Creating First Application User

I have been trying to do this lab and I have created the “m103-application-user” successfully, however when I try to validate the lab I am getting errors.

This is the output of db.getUsers() to confirm that I have created the user correctly:

[
	{
		"_id" : "admin.m103-admin",
		"user" : "m103-admin",
		"db" : "admin",
		"roles" : [
			{
				"role" : "root",
				"db" : "admin"
			}
		]
	},
	{
		"_id" : "admin.m103-application-user",
		"user" : "m103-application-user",
		"db" : "admin",
		"roles" : [
			{
				"role" : "readWrite",
				"db" : "applicationData"
			}
		]
	}
]

The error that I am getting when I try to validate the lab:

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.

Just for reference I will also include my mongod.conf file below:

storage:
    dbPath: "/var/mongodb/db/"
systemLog:
    logAppend: true
    path: "/var/mongodb/db/mongod.log"
    destination: "file"
net:
    port: 27000
    bindIp: "192.168.103.100,127.0.0.1"
security:
    authorization: "enabled"
processManagement:
    fork: true
operationProfiling:
    slowOpThresholdMs: 50

Any help is appreciated! Thank you!

Have you created the user correctly? and authenticated and able to connect to DB with userid/pwd

MongoDB Enterprise > db
admin
MongoDB Enterprise > db.auth(“m103-application-user”,“m103-application-pass”)
1

mongo -u m103-application-user -p m103-application-pass --authenticationDatabase applicationData --port 27000

I have the same problem.

db.auth(“m103-application-user”,“m103-application-pass”) get the response:
Error: Authentication failed.
0

vagrant@m103:~$ mongo admin --port 27000 -u m103-admin -p m103-pass
MongoDB shell version v3.6.12
connecting to: mongodb://127.0.0.1:27000/admin?gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“1023cf7f-4f86-484b-82a4-8a6e79c692e8”) }
MongoDB server version: 3.6.12
Server has startup warnings:
2019-04-15T03:09:08.310+0000 I STORAGE [initandlisten]
2019-04-15T03:09:08.310+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-04-15T03:09:08.310+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
MongoDB Enterprise > db
admin
MongoDB Enterprise > db.auth(“m103-application-user”,“m103-application-pass”)
Error: Authentication failed.
0
MongoDB Enterprise > db.getUsers()
[
{
“_id” : “admin.m103-admin”,
“user” : “m103-admin”,
“db” : “admin”,
“roles” : [
{
“role” : “root”,
“db” : “admin”
}
]
},
{
“_id” : “admin.m103-application-user”,
“user” : “m103-application-user”,
“db” : “admin”,
“roles” : [
{
“role” : “readWrite”,
“db” : “applicationData”
}
]
}

There must be wrong password. :frowning:

One solution that can work is delete the user m103-application-user and create again.

Kanika

yes, you are right! The password is wrong.

1 Like

I don’t think the password is wrong. I am able to authenticate just fine.

MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > db
admin
MongoDB Enterprise > db.auth("m103-application-user", "m103-application-pass")
1

Shouldn’t the --authenticationDatabase option be set to “admin” and not “applicationData”?

I believe the answer is ‘yes’ but the issue I seem to be stuck on is that the ‘applicationData’ DB doesn’t exist.

‘show dbs’ outputs the following:
MongoDB Enterprise > show dbs
admin 0.000GB
config 0.000GB
local 0.000GB

Is it that we have to first create the DB or should it already exist?

Will continue to think this through but a bit stuck.

@Kanika…thoughts?

Hi @Blake_99043,

In this lab, we create a user “m103-application-user” on admin database. However, this user is authorized on applicationData Database (since we gave that user readWrite access to the applicationData database).

applicationData DB doesn’t exist for now, but we can create it in later stage and the m103-application-user will have readWrite access to it.

Please let me know, if you have any further doubts.

Thanks,
Sonali

HI try do a tailf, in your log file, and check if you have the correct key, I have the same issue but i can loogin correctly

yeah, as far i understand, we need to authenticate against admin database, where is created the user, so we need to assing readWrite role to appData database

I am doing the below … Apparently the user is not created in the applicationData because of which i am unable to do a db.auth with the new users on applicationData DB

use admin
db.auth(“m103-admin”, “m103-pass”)

db.createUser({
user: “m103-application-user”,
pwd: “m103-application-pass”,
roles: [
{role: “readWrite”, db: “applicationData”}
]

db.getUsers()

Result is

MongoDB Enterprise > db.getUsers()
[
{
“_id” : “admin.m103-admin”,
“userId” : UUID(“6bc08bc2-7580-4639-8a96-a1e62a6e35eb”),
“user” : “m103-admin”,
“db” : “admin”,
“roles” : [
{
“role” : “root”,
“db” : “admin”
}
]
},
{
“_id” : “admin.m103-application-user”,
“userId” : UUID(“bd7eb4f1-e202-4cc6-9a29-47988617f679”),
“user” : “m103-application-user”,
“db” : “admin”,
“roles” : [
{
“role” : “readWrite”,
“db” : “applicationData”
}
]
}
]

Hi @,

Is there anything that you need help with here?

If yes, can you please elaborate your question as I can see the user exists in your db.

Thanks,
Muskan
Curriculum Support Engineer

So sorry , i didnt update !! It is all working fine now Thankks

I am getting same timeout error even my client successfully connected.

.
at client side

Hi @Milind_19368,

Please make sure that you have done the following things correctly :

  1. Created the configuration file correctly as described in the Lab - Creating First Application User.

  2. You have created the new user correctly with the right set of privileges as mentioned in the lab.

The requirements for this new user are:

* Role: readWrite on applicationData database
* Authentication source: admin
* Username: m103-application-user
* Password: m103-application-pass

If you have already done it, then please run these commands and share the output.

use admin
db.getUsers()

Thanks,
Shubham Ranjan
Curriculum Support Engineer

2 posts were split to a new topic: Error while validating Creating First Application User