/n8n-tutorials

How to reset admin credentials in n8n?

Learn how to reset admin credentials in n8n using CLI, database modification, environment variables, or Docker to regain access quickly and securely.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free consultation

How to reset admin credentials in n8n?

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:

  • Using the n8n Command Line Interface (CLI)
  • Directly modifying the database
  • Using environment variables to set new credentials
  • Resetting via the Docker container (if using Docker)

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:

  1. Go to Settings > Users
  2. Create a new admin user
  3. Stop n8n
  4. Restart without the N8N_AUTH_DISABLED environment variable

 

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:

  1. Access your n8n instance through the web interface
  2. Try logging in with the new credentials
  3. If successful, immediately go to your user settings and set a new secure password
  4. Make sure to document your new credentials securely for future reference

 

Step 9: Troubleshooting Common Issues

 

If you encounter problems while resetting your credentials:

  • Check that your n8n service is stopped before modifying the database directly
  • Ensure you have the correct database path for SQLite installations
  • Verify database credentials for PostgreSQL or MySQL databases
  • Check for proper permissions to execute the CLI commands
  • Ensure Docker container has the correct volumes mapped if using Docker

 

Step 10: Preventive Measures for the Future

 

To avoid future credential loss:

  • Set up a password manager to securely store your n8n credentials
  • Create a backup admin account with a different email address
  • Document your recovery procedure in a secure location
  • Consider using environment variables for credential management in production
  • Implement regular database backups to avoid data loss during recovery procedures

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022