Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Restore admin access in Rocket.Chat on Docker installations

Open Mongo shell within Mongo container

Change into docker-compose directory (where your docker-compose.yml is located):

cd /opt/docker/Rocket.Chat
docker-compose run mongo bash

Make sure to replace mongo with your MongoDB container name in case you use a different one.

On the Mongo shell:

use rocketchat

Make sure to replace rocketchat with your actual Mongo database. If you're not sure how it's called either check your docker-compose.yml file or run:

show dbs

Update admin password to 12345

db.getCollection('users').update({username:"administrator"}, { $set: {"services" : { "password" : {"bcrypt" : "$2a$10$n9CM8OgInDlwpvjLKLPML.eizXIzLlRtgCh3GRLafOdR9ldAUh/KG" } } } })

Make sure to restart your application container in case the new password is not accepted yet. Also replace administrator with the admin username in question.

Reset user role to "admin"

db.users.update({username:"administrator"}, {$set: {'roles' : [ "admin" ]}})

Again, make sure to replace administrator with the admin username in question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.