# MongoDB Authentication

**URL:** <https://forums.rocket.chat/t/mongodb-authentication/10012>\
**Category:** Community Support\
**Created:** [January 14, 2021, 4:56pm UTC](https://forums.rocket.chat/t/mongodb-authentication/10012 "2021-01-14T16:56:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![harrytuttle](https://avatars.discourse-cdn.com/v4/letter/h/3da27b/32.png) [@harrytuttle](https://forums.rocket.chat/u/harrytuttle)\
**Post date:** [January 14, 2021, 4:56pm UTC](https://forums.rocket.chat/t/mongodb-authentication/10012/1 "2021-01-14T16:56:11Z")

</div>

### Description

Hello,  
in an effort to make my Rocket.Chat Server more secure, I’d like to enable MongoDB Database Authentication. To achieve that, I changed the /etc/mongod.conf and added

```
security:
  authorization: "enabled"

```

Then I changed my databases accordingly:

```
use admin
show users
     {
                "_id" : "admin.rocketchat",
                "userId" : UUID("a95a7601-493d-4632-8ae5-bbe0358a1381"),
                "user" : "rocketchat",
                "db" : "admin",
                "roles" : [
                        {
                                "role" : "readWrite",
                                "db" : "local"
                        }
                ],
                "mechanisms" : [
                        "SCRAM-SHA-1",
                        "SCRAM-SHA-256"
                ]
        }

```

and also

```
use rocketchat
show users
{
        "_id" : "rocketchat.rocketchat",
        "userId" : UUID("83232493-b499-4041-813f-6bec70c4a2d5"),
        "user" : "rocketchat",
        "db" : "rocketchat",
        "roles" : [
                {
                        "role" : "dbOwner",
                        "db" : "rocketchat"
                }
        ],
        "mechanisms" : [
                "SCRAM-SHA-1",
                "SCRAM-SHA-256"
        ]
}

```

As described in [Connecting to a MongoDB server with authentication enabled · Issue #8856 · RocketChat/Rocket.Chat · GitHub](https://github.com/RocketChat/Rocket.Chat/issues/8856)  
I adapted the MONGO\_URL and MONGO\_OPLOG\_URL in /lib/systemd/system/rocketchat.service accordingly to  
`mongodb://rocketchat:mySecretPass@localhost:27017/rocketchat?authSource=admin`

Then I restarted both MongoDB and Rocket.Chat I opened Rocket.Chat in an Inkognito Tab but couldn’t log in, in fact I couldn’t even enter any login data, because the input fields merged into one:

 ![screenshot-rocketchat](https://us1.discourse-cdn.com/flex021/uploads/rocketchat/original/2X/c/cf39a2f47acebb9f3461e85378fb68b8e1f87ce9.jpeg)

What did I do wrong? Thanks for all answers in advance 🙂

### Server Setup Information

- Version of Rocket.Chat Server: 3.9.4
- Operating System: Debian 10 Buster (Kernel: Linux 4.19.0)
- Deployment Method: manual installation
- Number of Running Instances: 1
- NodeJS Version: v12.20.1
- MongoDB Version: 4.2.11
- Proxy: nginx
- Firewalls involved: ufw

---

<div class="post-metadata">

**Author:** ![IARI](https://sea1.discourse-cdn.com/flex021/user_avatar/forums.rocket.chat/iari/32/3404_2.png) [@IARI](https://forums.rocket.chat/u/IARI)\
**Post date:** [February 4, 2022, 10:17pm UTC](https://forums.rocket.chat/t/mongodb-authentication/10012/2 "2022-02-04T22:17:16Z")

</div>

Did you check rocketchat’s log?  
Did you find a solution?
