--- title: "Restore Admin User in Rocket Chat for Secure Access" slug: "restoring-an-admin-user" description: "Learn how to restore an admin user in Rocket Chat. Regain secure access, ensure governance, and maintain collaboration resilience across communication platforms." updated: 2026-03-03T14:57:40Z published: 2026-03-03T14:57:40Z canonical: "docs.rocket.chat/restoring-an-admin-user" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.rocket.chat/llms.txt > Use this file to discover all available pages before exploring further. # Restoring an Admin User In managing any digital platform, there may be instances where access to an admin user is lost and needs to be restored. This document guides you through the process of restoring an admin user in Rocket.Chat by accessing the database. This method does not require another admin user. ## Accessing the database Depending on how the Rocket.Chat server was installed, you can access the MongoDB database in various ways. The Mongo shell within the Mongo container can be accessed for Docker deployments, and for Ubuntu Snap installations, MongoDB can be connected directly. In this guide, we will follow the steps for Docker deployments. Run the following command to access the MongoDB shell: ```bash docker exec -it mongosh ``` Replace `<mongodb-container-name>` with your MongoDB container name. Next, switch to the Rocket.Chat database: ```javascript use rocketchat ``` Depending on your configuration, the database name may differ. You can run: ```javascript show dbs ``` to view available databases. --- ## Resetting the admin password Inside the Rocket.Chat database, set a temporary password for the admin user using the following command: ```javascript db.users.updateOne(  { username: "" },  { $set: { "services.password.bcrypt": "" } } ) ``` Replace the following values: - `<admin-username>`: The username of the admin account. - `<bcrypt-hash>`: A valid bcrypt hash of your temporary password. > [!WARNING] > Do not paste a plain text password here. You must generate a bcrypt hash first. --- ## Generating a valid Bcrypt Hash You can generate a bcrypt hash using Node.js or Python. ### Option 1: Using Node.js Run this in your terminal: ```bash node -e "console.log(require('bcryptjs').hashSync(process.argv[1], 10))" "TempPass123!" ``` Replace `TempPass123!` with your desired temporary password. ### Option 2: Using Python ```python python3 - <<'PY' import bcrypt pw = b"TempPass123!" print(bcrypt.hashpw(pw, bcrypt.gensalt(rounds=10)).decode()) PY ``` Copy the generated hash and paste it into the `updateOne` command. After running the MongoDB command, you should see output similar to: ```bash { acknowledged: true, matchedCount: 1, modifiedCount: 1 } ``` This confirms the password was updated. --- ## Logging in 1. Go to your Rocket.Chat login page. 2. Enter the admin username/email. 3. Use the **plain text temporary password** (e.g., `TempPass123!`). 4. You will be prompted to change your password. 5. Set a new secure password. You should now have full access again. --- ## Setting a User as Admin (optional) If you also need to grant admin privileges, run: ```javascript db.users.updateOne(  { username: "administrator" },  { $addToSet: { roles: "admin" } } ) ``` Using `$addToSet` ensures the `admin` role is not duplicated if it already exists.