M103 chapter 2 lab built-in roles

the lab question asks:

  1. Connect to a mongod instance that is already running in the background on port 27000 . You can find the options used to launch mongod in the configuration file in your file editor.The m103-admin user has also already been created for you with password m103-pass.

but when i issue:

mongo --username m103-admin --password m103-pass

i get this error:

2022-01-15T14:03:06.037+0000 E QUERY    [js] Error: couldn't connect to server, connection attempt failed: SocketException: Error connecting to :: caused by :: Connection refused :
exception: connect failed

If you see the error message it is trying to connect to mongod on port 27017 (default port)

Pass correct port_num to your command

but in the question it says

Connect to a mongod instance that is already running in the background on port 27000

also the configuration file is:

  dbPath: /var/mongodb/db
  bindIp: localhost
  port: 27000
  authorization: enabled
  destination: file
  path: /var/mongodb/logs/mongod.log
  logAppend: true
  fork: true

also i can not re run mongod with:

mongod -f mongod.conf

because i get this error:

about to fork child process, waiting until server is ready for connections.
forked process: 368
ERROR: child process failed, exited with error number 48
To see additional information in this output, start without the "--fork" option.

That is correct
You have to connect to mongod running on port 27000

Did you try as i suggested giving port 27000?

mongo -u xyz -p xyz -port 27000

When you issue mongo command without giving the port number it will try to connect to default mongod which runs on port 27017
Since it is not running on 27017 your connect is failing
Try as i shown above.No need to start mongod again with config file as you are trying