{"record":{"id":"b8e268656fc6112b","repo":"immich-app/immich","slug":"admin-account-does-not-exist","errorCode":null,"errorMessage":"Admin account does not exist","messagePattern":"Admin account does not exist","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/src/services/cli.service.ts","lineNumber":65,"sourceCode":"      }\n    }\n\n    const drift = await this.databaseRepository.getSchemaDrift();\n\n    return { migrations, drift };\n  }\n\n  async listUsers(): Promise<UserAdminResponseDto[]> {\n    const users = await this.userRepository.getList({ withDeleted: true });\n    return users.map((user) => mapUserAdmin(user));\n  }\n\n  async resetAdminPassword(\n    ask: (admin: UserAdminResponseDto) => Promise<{ newPassword: string | undefined; invalidateSessions: boolean }>,\n  ) {\n    const admin = await this.userRepository.getAdmin();\n    if (!admin) {\n      throw new Error('Admin account does not exist');\n    }\n\n    const { newPassword: providedPassword, invalidateSessions } = await ask(mapUserAdmin(admin));\n    const password = providedPassword || this.cryptoRepository.randomBytesAsText(24);\n    const hashedPassword = await this.cryptoRepository.hashBcrypt(password, SALT_ROUNDS);\n\n    await this.userRepository.update(admin.id, { password: hashedPassword });\n\n    if (invalidateSessions) {\n      await this.sessionRepository.invalidateAll({ userId: admin.id });\n    }\n\n    return { admin, password, provided: !!providedPassword };\n  }\n\n  async disablePasswordLogin(): Promise<void> {\n    const config = await this.getConfig({ withCache: false });\n    config.passwordLogin.enabled = false;","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/server/src/services/cli.service.ts#L47-L83","documentation":"The `resetAdminPassword` CLI command looks up the administrator account via userRepository.getAdmin() before prompting for a new password. If no admin account exists, it throws this plain Error, since resetting an admin password is meaningless without one. Typically indicates a corrupted or wiped user table.","triggerScenarios":"Running `immich-admin reset-admin-password` when no user row with isAdmin=true exists in the database.","commonSituations":"Database restored from a partial/old backup missing the admin row; admin user deleted via API or SQL; fresh database used with the admin CLI before initial setup.","solutions":["Recreate the admin account (first registered user must be admin) before resetting its password.","Check the database: SELECT * FROM \"user\" WHERE \"isAdmin\" = true; to confirm the admin row exists.","Point the CLI at the correct database via environment variables — it may be connected to an empty/wrong DB.","Restore the missing admin row from backup or re-run initial server setup."],"exampleFix":"// before\n$ immich-admin reset-admin-password   // throws: Admin account does not exist\n// after\n$ immich-admin create-user --admin    # or create admin via setup wizard first\n$ immich-admin reset-admin-password","handlingStrategy":"try-catch","validationCode":"// Verify an admin exists before invoking the CLI reset\nconst admin = await db.query('SELECT id FROM \"user\" WHERE \"isAdmin\" = true LIMIT 1');\nif (!admin.rows.length) throw new Error('Create the admin account first');","typeGuard":null,"tryCatchPattern":"try {\n  await resetAdminPassword(promptFn);\n} catch (e) {\n  if (e.message === 'Admin account does not exist') {\n    // bootstrap admin first, then retry\n  } else throw e;\n}","preventionTips":["Never delete the admin row directly in SQL.","Confirm the CLI's database connection env vars point at the live instance.","Keep verified database backups that include the user table."],"tags":["cli","user-management","admin-required","database"],"backgroundTag":"user-not-found","analyzedSha":"e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c","analyzedAt":"2026-09-15T07:20:19.675Z","contentChangedAt":"2026-09-15T07:20:19.675Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}