immich-app/immich · error · Error

Admin account does not exist

Error message

Admin account does not exist

What it means

Thrown (as a plain Error, not an HTTP exception) by CliService.resetAdminPassword when userRepository.getAdmin() returns null. The CLI admin-password-reset flow assumes an admin already exists; on an unbootstrapped system there is nothing to reset.

Source

Thrown at server/src/services/cli.service.ts:66

      }
    }

    const drift = await this.databaseRepository.getSchemaDrift();

    return { migrations, drift };
  }

  async listUsers(): Promise<UserAdminResponseDto[]> {
    const users = await this.userRepository.getList({ withDeleted: true });
    return users.map((user) => mapUserAdmin(user));
  }

  async resetAdminPassword(
    ask: (admin: UserAdminResponseDto) => Promise<{ newPassword: string | undefined; invalidateSessions: boolean }>,
  ) {
    const admin = await this.userRepository.getAdmin();
    if (!admin) {
      throw new Error('Admin account does not exist');
    }

    const { newPassword: providedPassword, invalidateSessions } = await ask(mapUserAdmin(admin));
    const password = providedPassword || this.cryptoRepository.randomBytesAsText(24);
    const hashedPassword = await this.cryptoRepository.hashBcrypt(password, SALT_ROUNDS);

    await this.userRepository.update(admin.id, { password: hashedPassword });

    if (invalidateSessions) {
      await this.sessionRepository.invalidateAll({ userId: admin.id });
    }

    return { admin, password, provided: !!providedPassword };
  }

  async disablePasswordLogin(): Promise<void> {
    const config = await this.getConfig({ withCache: false });
    config.passwordLogin.enabled = false;

View on GitHub (pinned to 199723261c)

Solutions

  1. Bootstrap the instance first (create the initial admin via the web setup flow or setup CLI).
  2. Confirm DATABASE_URL points at the intended database that actually contains the admin user.
  3. If the admin was deleted, recreate one before attempting a password reset.

Example fix

// before
await cliService.resetAdminPassword(prompt);

// after
const admin = await userRepository.getAdmin();
if (!admin) {
  console.error('No admin account found. Complete initial setup first.');
  process.exit(1);
}
await cliService.resetAdminPassword(prompt);
Defensive patterns

Strategy: validation

Validate before calling

if (!(await userRepository.hasAdmin())) {
  console.error('No admin account; complete initial setup before resetting password.');
  process.exit(1);
}

Prevention

When it happens

Trigger: Running the CLI command that resets the admin password against a database that has no admin user (fresh install, wiped DB, or partial migration).

Common situations: Running the reset-admin-password CLI before initial onboarding; against a database restored from a dump that lacked the admin row; wrong DATABASE_URL pointing at an empty schema.

Related errors


AI-assisted analysis of immich-app/immich@199723261c (2026-08-12). Data as JSON: /api/errors/b8e268656fc6112b. Report an issue: GitHub.