Cannot start as admin

I think I had everything right up to this point, and that the command is good, so I’m befuddled.

user@M103# mongo --host “m103-repl/localhost:27001” -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin”
MongoDB shell version v4.0.5
connecting to: mongodb://localhost:27001/?authSource=admin&gssapiServiceName=mongodb&replicaSet=m103-repl
2021-10-14T16:30:23.206+0000 I NETWORK [js] Starting new replica set monitor for m103-repl/localhost:27001
2021-10-14T16:30:23.233+0000 W NETWORK [js] Unable to reach primary for set m103-repl
2021-10-14T16:30:23.233+0000 I NETWORK [js] Cannot reach any nodes for set m103-repl. Please check network connectivity and the status of the set. This has happened for 1 checks in a row.
2021-10-14T16:30:28.738+0000 W NETWORK [js] Unable to reach primary for set m103-repl
2021-10-14T16:30:33.242+0000 W NETWORK [js] Unable to reach primary for set m103-repl
2021-10-14T16:30:33.242+0000 I NETWORK [js] Cannot reach any nodes for set m103-repl. Please check network connectivity and the status of the set. This has happened for 21 checks in a row.
2021-10-14T16:30:37.746+0000 W NETWORK [js] Unable to reach primary for set m103-repl
2021-10-14T16:30:37.746+0000 E QUERY [js] Error: connect failed to replica set m103-repl/localhost:27001 :
connect@src/mongo/shell/mongo.js:328:13
@(connect):1:6
exception: connect failed

Since a server is running at 27001, I suspect that you might have forgot to run rs.initiate().

Try to connect with

mongo --port 27001 -u "m103-admin" -p "m103-pass"

and then share the output of the command

rs.status()

Thanks. Figured it out.

Please share the solution so that other have some clues if they have the same issue.

1 Like