# Can't connect with any user to any db

**URL:** <https://forums.percona.com/t/cant-connect-with-any-user-to-any-db/14796>\
**Category:** Percona Operator for MongoDB\
**Created:** [March 18, 2022, 8:11am UTC](https://forums.percona.com/t/cant-connect-with-any-user-to-any-db/14796 "2022-03-18T08:11:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jpuntas](https://avatars.discourse-cdn.com/v4/letter/j/94ad74/32.png) [@jpuntas](https://forums.percona.com/u/jpuntas)\
**Post date:** [March 18, 2022, 8:11am UTC](https://forums.percona.com/t/cant-connect-with-any-user-to-any-db/14796/1 "2022-03-18T08:11:38Z")

</div>

Hi!

first of all, i am a completely newbie whit mongo and kubernetes. Sorry if i miss important info!

I installed all using this manual [Generic Kubernetes installation - Percona Operator for MongoDB](https://www.percona.com/doc/kubernetes-operator-for-psmongodb/kubernetes.html)

I only change, cluster name from my-cluster-name on avery \*.yaml file to mongo-bo. Also, i change passwords on secrets.yaml and from cr.yaml the option to make a load balancer.

I ended installation with no errors, load balancer works fine, i can access from an external computer using mongo --host xx.xx.xx.xx

But when i tried to list dbs, i get this error  
mongos\> use admin  
switched to db admin  
mongos\> show users  
2022-03-18T09:05:05.582+0100 E QUERY [thread1] Error: command usersInfo requires authentication :  
\_getErrorWithCode@src/mongo/shell/utils.js:25:13  
DB.prototype.getUsers@src/mongo/shell/db.js:1523:1  
shellHelper.show@src/mongo/shell/utils.js:744:9  
shellHelper@src/mongo/shell/utils.js:651:15  
@(shellhelp2):1:1

if i use mongo --host xx.xx.xx.xx -u userAdmin -p anypassword  
mongo ask me again form password. But i can write anything, rigth password or ramdom characters and always get the same error

$ mongo -host XX.XX.XX.XX -u useradmin -p asdasdas  
MongoDB shell version: 3.2.11  
Enter password:  
connecting to: XX.XX.XX.XX:27017/asdasdas  
2022-03-18T09:07:13.209+0100 E QUERY [thread1] Error: Authentication failed. :  
DB.prototype.\_authOrThrow@src/mongo/shell/db.js:1441:20  
@(auth):6:1  
@(auth):1:2

exception: login failed

and finally i found this part of manual, [Application and system users - Percona Operator for MongoDB](https://www.percona.com/doc/kubernetes-operator-for-psmongodb/users.html)

i can start percona-client, but i cant connect

kubectl run -i --rm --tty percona-client --image=percona/percona-server-mongodb:4.4.10-11 --restart=Never – bash -il

> > percona-client:/$ mongo “mongodb://userAdmin:userAdmin123456@my-cluster-name-mongos..svc.cluster.local/admin?ssl=false”  
> > If you don’t see a command prompt, try pressing enter.  
> > [mongodb@percona-client /]$ mongo  
> > Percona Server for MongoDB shell version v4.4.10-11  
> > connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb  
> > Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :  
> > connect@src/mongo/shell/mongo.js:374:17  
> > @(connect):2:6  
> > exception: connect failed  
> > exiting with code 1

don’t matter which user/pass i use.

Any help please???

Thanks in advance

---

<div class="post-metadata">

**Author:** ![Sergey\_Pronin](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/sergey_pronin/32/14887_2.png) [@Sergey\_Pronin](https://forums.percona.com/u/Sergey_Pronin)\
**Post date:** [March 21, 2022, 8:30am UTC](https://forums.percona.com/t/cant-connect-with-any-user-to-any-db/14796/2 "2022-03-21T08:30:45Z")

</div>

Hello @jpuntas ,

we create two system users that you can use to connect to MongoDB and do something:

- clusterAdmin - has [clusterAdmin](https://docs.mongodb.com/manual/reference/built-in-roles/#mongodb-authrole-clusterAdmin) role
- userAdmin - has [userAdmin](https://docs.mongodb.com/manual/reference/built-in-roles/#mongodb-authrole-userAdmin) role

userAdmin can create new users granting access to databases and other magic.

About connecting to DB, first of I see the typo in here:

```auto
percona-client:/$ mongo “mongodb://userAdmin:userAdmin123456@my-cluster-name-mongos..svc.cluster.local/admin?ssl=false”

```

I think you skipped the namespace and also should use your cluster name (is it mongo-bo)?. So it should be something like this for default namespace:

```auto
percona-client:/$ mongo “mongodb://userAdmin:userAdmin123456@mongo-bo-mongos.default.svc.cluster.local/admin?ssl=false”

```

If it does not help - please show me your `kubectl get services` and I will try to help more.
