Validate_lab_import_dataset is throwing error - 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 am able to import the json file, but it is not validating and keep throwing

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.

There was no port specified in the final part, so it should be the last one 27000, but it is not verifying

Please check that mongod is running on the correct port.

1 Like

Just to add to steevej-1495 post. Port 27000 is not the default port that mongo will run on.

Hi @sherazahmed,

Please check your steps once again -

  • Are you running your process using the correct port and correct IP addresses?
  • How did you connect to mongo when creating the new user and the db that you created the user in?

You can also go through the following post to see if it can be of any help to you.

Thanks,
Muskan
Curriculum Support Engineer

I am getting the same error on ‘validate_lab_import_dataset’. However, ‘validate_lab_first_application_user’ runs without error (which means mongod is running on correct port and has the user). I have checked mongod is listening to 27000 and the user is created correctly. Did anyone solve this issue?

Please check mongod is still running on port 27000 (ps -ef|grep mongo)
Are you able to connect with the application user?
Did your import went fine
What collections you see and product count

Hi @subedi.bdr,

Yes, you are supposed to have the same mongod instance up and running which you have had in the previous Lab - Creating First Application User.

Please make sure that before you run the mongoimport command, the mongod instance is up and running.

You can verify that your mongod instance is running by running the command mentioned below.

ps -ef | grep mongod

If in case your mongod process is running and you are still getting the error then please share the following in the personal chat :

  1. Command used to import the dataset
  2. Command that you used to run the mongod instance.

Note:- I have created a thread for our personal chat if in case you are sharing the commands.

Thanks,
Shubham Ranjan
Curriculum Support Engineer

I have the same issue.

I am on port 2700. I confirmed in the shell (port 27000) after evaluating db.auth(“m103-application-user”,“m103-application-pass”) that the import worked.

I am running mongod using the same config file used in the previous exercise

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

vagrant@m103:~$ ps -ef | grep mongod
vagrant 2046 1 3 22:20 ? 00:00:01 mongod --config /shared/mongod_3.cfg
vagrant 2077 1941 0 22:21 pts/0 00:00:00 grep --color=auto mongod

and

mongo --port 27000

then

show users
{
	"_id" : "admin.m103-admin",
	"userId" : UUID("ba1dc045-7c01-478b-9732-67e5ce2a4516"),
	"user" : "m103-admin",
	"db" : "admin",
	"roles" : [
		{
			"role" : "userAdminAnyDatabase",
			"db" : "admin"
		},
		{
			"role" : "dbOwner",
			"db" : "admin"
		},
		{
			"role" : "clusterAdmin",
			"db" : "admin"
		}
	]
}
{
	"_id" : "admin.m103-application-user",
	"userId" : UUID("377ab9be-88d5-43a5-b80a-5d28a7981dfc"),
	"user" : "m103-application-user",
	"db" : "admin",
	"roles" : [
		{
			"role" : "readWrite",
			"db" : "applicationData"
		}
	]
}

also

db.products.find().count()
516784

but

vagrant@m103:~$ validate_lab_import_dataset

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.

@mikeh1980 that’s weird! Might just be something temporary.

Login to MongoDB using the following five commands and let’s see the screenshot output (including the command). Please copy and paste as-is without making any amends:

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

Restarted computer. Restarted mongod using the config file. Tried validate_lab_import_dataset again but got the same result. Here are the screen grabs.


This is potentially the problem. You created this user twice authenticating on two different databases. Suggest you delete this user from both the applicationData and admin databases, then recreate it on the admin db alone.

delete user from admin and applicationData.

Deleted the database.

show applicationData to make a new db

use admin

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

exit the shell.

imported the data

vagrant@m103:~$ mongoimport --port=27000 --db “applicationData” --collection “products” --username “m103-application-user” --password “m103-application-pass” --authenticationDatabase “admin” /dataset/products.json

2019-12-09T06:00:28.087+0000 connected to: localhost:27000

2019-12-09T06:00:31.075+0000 [####…] applicationData.products 17.4MB/87.9MB (19.7%)

2019-12-09T06:00:34.075+0000 [#########…] applicationData.products 34.9MB/87.9MB (39.6%)

2019-12-09T06:00:37.075+0000 [##############…] applicationData.products 52.2MB/87.9MB (59.4%)

2019-12-09T06:00:40.075+0000 [###################…] applicationData.products 69.8MB/87.9MB (79.4%)

2019-12-09T06:00:43.071+0000 [########################] applicationData.products 87.9MB/87.9MB (100.0%)

2019-12-09T06:00:43.071+0000 imported 516784 documents

vagrant@m103:~$ validate_lab_import_dataset

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.

WTF?

Hi @mikeh1980,

This is very strange. Can you please make sure that the mongod instance is up and running when you are running the validation script ?

In addition to this, connect to your mongod instance and run this command on admin database and share the output.

db.runCommand({getCmdLineOpts:1})

Thanks,
Shubham Ranjan
Curriculum Support Engineer

We already established that mongod was running via various tests i was asked to run previously, plus other information i supplied. Asking me to make sure mongod is running is unhelpful.

Anyway here is a screen grab after db.runCommand({getCmdLineOpts:1})

Are you able to connect with application user?
mongo -u m103-application-user -p m103-application-pass --authenticationDatabase admin --port 27000
Have you authenticated this user?

Yeah @Ramachandra_37567, he’s done all that with success in a prior post.

I’ve ran a few tests and it turns out that the validator uses m103-admin and not the application user. And we have established that m103-admin can authenticate against the admin db. I think something abnormal is happening on @mikeh1980’s setup.

@mikeh1980, suggest that you rebuild the server by doing the following:

  1. shutdown the server (i.e. run db.shutdownServer() on the admin db) or kill the process
  2. delete the /var/mongodb/db sub directory and recreate it
  3. fire up mongod
  4. create the m103-admin user on the admin db and authenticate as this user
  5. create the application user and logout
  6. run mongoimport
  7. login once more as m103-admin and perform a record count
  8. run the validator

It worked.

I worked through all your steps but tbh there didn’t seem to be anything there that I didn’t do previously