Learn how to reset admin credentials in n8n using CLI, database modification, environment variables, or Docker to regain access quickly and securely.
Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
To reset admin credentials in n8n, you can use either the command line interface, manipulate the database directly, or set up new credentials via environment variables. These methods work when you've forgotten your admin password or need to recover access to your n8n instance.
Step 1: Understand the Available Methods for Resetting Admin Credentials
Before proceeding with resetting your n8n admin credentials, you should understand the different methods available:
The method you choose will depend on your n8n installation type and your access level to the system.
Step 2: Reset Admin Password Using the CLI
If you have command-line access to your n8n installation, this is the easiest method:
n8n user-management:reset
This command will reset all users to the default credentials:
For more control, you can specify a specific user to reset:
n8n user-management:reset [email protected]
Step 3: Reset Password by Directly Modifying the Database
If you have access to your n8n database, you can directly modify the credentials:
For SQLite database:
sqlite3 ~/.n8n/database.sqlite
# Once in the SQLite shell, run:
UPDATE "user" SET "password" = '$2a$10$Cdxy2.j6KmiZ3veFf5SaUuHYfxEKQZMOZlI2vgx5ptA.I9zzvp2wG' WHERE "email" = '[email protected]';
.exit
This sets the password to "password" for the specified email.
For PostgreSQL database:
psql -U [username] -d [database\_name]
# Once in the PostgreSQL shell, run:
UPDATE "user" SET "password" = '$2a$10$Cdxy2.j6KmiZ3veFf5SaUuHYfxEKQZMOZlI2vgx5ptA.I9zzvp2wG' WHERE "email" = '[email protected]';
\q
For MySQL/MariaDB database:
mysql -u [username] -p [database\_name]
# Once in the MySQL shell, run:
UPDATE `user` SET `password` = '$2a$10$Cdxy2.j6KmiZ3veFf5SaUuHYfxEKQZMOZlI2vgx5ptA.I9zzvp2wG' WHERE `email` = '[email protected]';
exit;
Step 4: Reset Credentials Using Environment Variables
You can set new admin credentials using environment variables when starting n8n:
export [email protected]
export N8N_AUTH_PASSWORD=new\_password
n8n start
This method works if you have access to configure environment variables for your n8n instance.
Step 5: Reset Credentials in Docker Environment
If you're running n8n in a Docker container, you can:
docker exec -it [container\_name] n8n user-management:reset
Or you can reset using environment variables in your docker-compose.yml file:
version: '3'
services:
n8n:
image: n8nio/n8n
ports:
- "5678:5678"
environment:
- N8N_AUTH_USERNAME=new\[email protected]
- N8N_AUTH_PASSWORD=new_secure_password
volumes:
- ~/.n8n:/home/node/.n8n
Then restart your Docker container:
docker-compose down
docker-compose up -d
Step 6: Disable Authentication Temporarily
If all else fails, you can temporarily disable authentication, access the instance, and set up new credentials:
export N8N_AUTH_DISABLED=true
n8n start
For Docker:
docker run -it --rm \\
-p 5678:5678 \\
-e N8N_AUTH_DISABLED=true \\
-v ~/.n8n:/home/node/.n8n \\
n8nio/n8n
Once you access the n8n UI, you can:
Step 7: Reset via a Custom Script
For advanced users, you can create a script to reset credentials. Save this as reset-n8n-password.js:
const bcrypt = require('bcryptjs');
const { Db } = require('n8n-core');
async function resetPassword() {
const email = '[email protected]'; // Email to reset
const newPassword = 'new\_password'; // New password
const db = new Db();
await db.init();
const hashedPassword = await bcrypt.hash(newPassword, 10);
await db.collections.User.update(
{ email },
{ password: hashedPassword }
);
console.log(`Password reset for ${email}`);
process.exit(0);
}
resetPassword().catch(error => {
console.error('Error resetting password:', error);
process.exit(1);
});
Run it with:
cd /path/to/n8n
node reset-n8n-password.js
Step 8: Verify Your New Credentials
After resetting your credentials using any of the methods above:
Step 9: Troubleshooting Common Issues
If you encounter problems while resetting your credentials:
Step 10: Preventive Measures for the Future
To avoid future credential loss:
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.