Chapter 1: The Mongod - Lab: Configuration File (error: No such file or directory)

Hello all!

I’m really new to this stuff. I’m trying to finish the second lab of the first chapter with the following config file:

dbPath: “/data/db”
destination: file
path: “/data/logs”
replSetName: “M103”
port: 27000
bindIp: “,”
authorization: “enabled”
keyFile: “/data/keyfile”
fork: false

When I try to run Mongo, I get the following error:

sh-4.4# mongod --config mongod.conf
Error reading config file: No such file or directory
try ‘mongod --help’ for more information
sh-4.4# mongod --config mongod.conf --port 27000 --auth
Error reading config file: No such file or directory
try ‘mongod --help’ for more information

I tried to reset the workspace, update the page and nothing works. The following command works just fine but it is not enough to pass the lab:

sh-4.4# mongod --auth --port 27000

Any help would be much appreciated.

Thanks a lot in advance!

It says file not found
Where is your config file located?
Also in IDE environment will not work
So remove it from your config file and also any unneeded params if any

The last command worked from command line as you have passed minimum params like auth & port
But your lab is about configuration file
So try to correct your config file and try again
Make sure to kill any already running mongods on same port

1 Like

Hi @jrazpeitia,

I hope you found @Ramachandra_37567’s response helpful.

Please reread the instructions mentioned in the lab and compare that with the content of your configuration file and see if you really need those parameters.

For assistance, you can refer this resource : - Configuration File Options

Let us know if you have any face difficulty.

~ Shubham

Hey folks, I am experiencing the same problem here.
When I try to run mongo with a conf file as simple as this:

  dbPath: /data/db
  port: 27000
  keyFile: /data/keyfile

I get the No such file or directory error, as below:

sh-4.4# mongod -f mongod.conf
2020-05-18T18:20:55.360+0000 I CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2020-05-18T18:20:55.366+0000 I ACCESS   [main] Error reading file /data/keyfile: No such file or directory

If I cut those authencation options out, I manage to put the server up and running, but on the other hand, it fails all the tests. So is there anything else I’m missing? Shouldn’t there be a file called keyfile along with the mongod.conf in the file explorer?

There is only 2 requirements for this lab. I do not recall having any requirements for storage or keyfile. Is there any other line after the keyfile error? You have to stick to the written requirements.

No. That’s the thing. On one hand, If I don’t pass keyfile, the mongod process starts normally but all the tests fail. On the other hand, if I do pass the keyfile the mongod process doesn’t even start

  port: "27000"
  authorization: "enabled"

Look, even with a conf file as simples as this one above, the mongod process starts up but the tests fail when a click run test

3 total, 1 passed, 0 skipped:
[PASS] "The server is running on localhost:27000"
[FAIL] "The server requires authentication"
(in test file /tmp/, line 15)
`[[ "$output" =~ command\ usersInfo\ requires\ authentication ]]' failed with status 252

Don't forget to launch mongod with authentication enabled!
You can do this using the configuration file.

According to Mongo Docs, you have to inform a keyfile along with the authorization value for authentication to work.

Okay, thanks to this guy:

Just needed to create the user in the db before running the tests. :+1:

The 3rd step of this lab is:

Once mongod is running, open a new Terminal window and use the following command to create an admin user. You will need to create this user in order to validate your work.

Even the bold is in the description of the lab.

1 Like

Hi @jrazpeitia,

Let us know if you are still facing any issue.

~ Shubham

2 posts were split to a new topic: [FAIL] Mongod was started with a configuration file