Unable to initiate mongod using the config file


I am unable to start the mongod using below config file

vagrant@m103:~$ cat mongod.conf

vagrant@m103:~$ mongod --config mongod.conf
Unrecognized option: security
try ‘mongod --help’ for more information

Looks like indentation issue
How does authorization look in your config file
It has to be 2-3 spaces to the right under security
Also try to give space after colon,with and without quotes etc

1 Like

Why do i get this error


i am able to run mongoDB only on port 30000 , why so ???

When you type mongo it will try to connect to default port 27017 as you can see in your screenshot
Is mongod up and running on port 27017?

Please start mongod just typing mongod–> it will start mongod using default dirs
You can verify by ps -ef|grep mongod
Then open another session and try to connect by typing mongo
You should be able to connect
You are able to connect to port 30000 as mongod is up and running

If you have initiated mongod with port 30000 then you have to start the mongo shell with port 30000.

Try mongo --port 30000

Simply giving mongo will try for port 27017 and will fail as there is no instance with 27017.

I tried with 2-3 spaces too.


Now the error shows
Error parsing YAML config file: yaml-cpp: error at line 4, column 8: illegal map value

I changed the extension from mongod.conf to mongod.yaml.
It started working.

Thank you for your help.

1 Like

i did not anything as such explicitly, can you guide me through the same?


Copy the file content and go to online YAML validater and validate it once againg bcz I was getting the same error and found out that the space was causing the problem(After the colon a space must required).

1 Like

Thank you guys.
Its resolved.
I changed the file extension.
mongod.conf to mongod.yaml

And it started working.

1 Like

Hi @laxmi_51996,

As I can check, you have successfully finished the lab.
However, if you still face any issues, please let me know.


Bro, this is really nice advice - try it on validater! Thank you so much!

You don’t need to change the format of your file,
but you need to check your syntax:
dbPath: /data/db - no quotes!
authorization: enabled - no quotes!
And also you don’t need to use net two times.

hi, after creating mkdir -p /var/mongodb/db/node1
how can I write below configuration for node1.conf
dbPath: /var/mongodb/db/node1
port: 27011
authorization: enabled
keyFile: /var/mongodb/pki/m103-keyfile
destination: file
path: /var/mongodb/db/node1/mongod.log
logAppend: true
fork: true
replSetName: m103-example

1 Like

Open vi editor
Paste the contents and save the file
Make sure indentation is proper for YAML format

1 Like

I have created 03 separate node1.cfg, node2.cfg and node3.cfg in Notepad ++. Now I would like to start mongod process using each node.cfg files. but i dont know how to push this file to vagrant local server.

Please create config files under C:…\M103\m103-vagrant-env\shared directory

cd /shared on vagrant Unix box(m103)
ls -lrt
You should be able to see the files

Hi @yatinpatel13983,

Please create and save your config files at the location mentioned by @Ramachandra_37567.

Post that you may launch your mongod process as explained in the lectures/lecture notes using the following invocation - mongod -f *//config file path//*

Curriculum Support Engineer

hi when i execute openssl rand -base64 741 > /var/mongodb/pki/m103-keyfile
it says Permission denied.

then when I try to start mongod it says below error

mongod -f mongod-repl-1.conf
Error reading config file: No such file or directory
try ‘mongod --help’ for more information

I am getting error when I execute below:
“ok” : 0,
“errmsg” : “Quorum check failed because not enough voting nodes responded; required 2 but only the following 1 voting nodes responded:; the following nodes did not respond affirmatively: m103-repl/ failed with HostUnreachable”,
“code” : 74,
“codeName” : “NodeNotFound”,
“operationTime” : Timestamp(1564456834, 1),
“$clusterTime” : {
“clusterTime” : Timestamp(1564456834, 1),
“signature” : {
“keyId” : NumberLong(0)