My mongo d instance says im not its master

while doing the replication set lab i tried to create a user on my primary node without having connected the others yet but when i make the create user command

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

it gives me this error

2020-02-14T09:30:57.589+0000 E QUERY [thread1] Error: couldn’t add user: not master :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1437:15
@(shell):1:1

i tried disconnecting and reconnecting to it and it continues to give me this error even though im connecting through the local host and no other users have been created. i dont think that its due to me having lost the local host exception because it gave me this error the first time i logged in before i tried any other commands.

thanks in advance for any help

You need to initiate the replica set before creating the first user.

3 Likes

thank you very much but now that ive made the user and initiated the repl set apparently the replica set ids dont match and i cant add my other nodes

I don’t follow. Perhaps share a screenshot of the problem or error you’re getting.

If it complains that the replica sets ids are not the same then restart all the nodes with the same ids.

Hi @Hyrum_58532,

If you are still facing this issue then please share the output of the rs.add(…) command that you are using to add the nodes in the replica set.

Thanks,
Shubham Ranjan
Curriculum Services Engineer