Couldn't add user

uncaught exception: Error: couldn’t add user: there are no users authenticated :Screenshot (11)

Hi @Shraddha_58636,

It looks like that you have already created the user. Remember, you can use the localhost exception to create the user only once. Once created, you must authenticate as the user administrator to create any other user.

Either use the db.auth() method to authenticate or append the username and password at the end of your connection string.

In addition to this, please do all the operations inside the Vagrant environment only as a good practice. As I can see in the screenshot, you are running the mongo command on your host machine.

Hope it helps!

Please feel free to get back to us if you have any other query :slight_smile: .

Thanks,
Shubham Ranjan
Curriculum Services Engineer

i delete my user which is previously created on localhost admin database. then i go to
192.168.103.100 then try to create user in same way still its not working
please revert,

Hi @Shraddha_58636,

It looks like you are doing all the operations on your host machine and not inside the vagrant machine. I have mentioned it earlier as well.

Please run the following command to get inside the m103-vagrant machine.

vagrant up (run this command only if your vagrant machine is not running)

vagrant ssh

Thanks,
Shubham Ranjan
Curriculum Services Engineer

now m doing it in vagrant environment…

As your screenshot indicates –auth is not a valid option.

As your screenshot indicates there are no users authenticated so you have to authenticate in order to do anything.

If you have no users in your database, you must use the localhost exception in order to create the first user. I do not think that specifying –host 192… allows you to use the localhost exception.

Hi @Shraddha_58636,

In addition to @steevej-1495,

Kill the currently running mongod instance and start it without the --auth option. Please run the mongod instance on the vagrant machine only.

Now connect to your mongod instance using this command :

mongo --port 27000

use admin

db.getUsers()

Please share the following information :

  1. Screenshot of how you ran the mongod command.
  2. Screenshot of the output of the db.getUsers() command.

Thanks,
Shubham Ranjan
Curriculum Services Engineer