immich-app/immich · error · BadRequestException
The first registered account must the administrator.
Error message
The first registered account must the administrator.
What it means
Thrown by BaseService.createUser when a non-admin user is being created (dto.isAdmin is false) but userRepository.getAdmin() returns nothing. Immich requires the very first account to be the administrator, so creating a regular user before any admin exists is blocked.
Source
Thrown at server/src/services/base.service.ts:305
}
async requireSetupAvailable(): Promise<void> {
if (!(await this.isSetupAvailable())) {
throw new BadRequestException('Admin setup is not available');
}
}
async createUser(dto: Insertable<UserTable> & { email: string }): Promise<UserAdmin> {
const exists = await this.userRepository.getByEmail(dto.email);
if (exists) {
this.logger.debug('User creation rejected: user already exists');
throw new BadRequestException('Email is not available');
}
if (!dto.isAdmin) {
const localAdmin = await this.userRepository.getAdmin();
if (!localAdmin) {
throw new BadRequestException('The first registered account must the administrator.');
}
}
const payload: Insertable<UserTable> = { ...dto };
if (payload.password) {
payload.password = await this.cryptoRepository.hashBcrypt(payload.password, SALT_ROUNDS);
}
if (payload.storageLabel) {
payload.storageLabel = sanitize(payload.storageLabel.replaceAll('.', ''));
}
const user = await this.userRepository.create(payload);
await this.eventRepository.emit('UserCreate', user);
return user;
}
}View on GitHub (pinned to 199723261c)
Solutions
- Make the first user-creation call on a fresh system set isAdmin: true.
- Run the admin bootstrap/onboarding step before any non-admin provisioning.
- If an admin was accidentally deleted, restore it or re-run setup with isAdmin=true before adding users.
Example fix
// before
await userService.createUser({ email, isAdmin: false, ...rest });
// after
const hasAdmin = await userRepository.hasAdmin();
await userService.createUser({ email, isAdmin: !hasAdmin, ...rest }); Defensive patterns
Strategy: validation
Validate before calling
const isFirstUser = !(await userRepository.hasAdmin());
await userService.createUser({ ...dto, isAdmin: isFirstUser }); Prevention
- Make first-run registration force isAdmin=true automatically.
- Run the admin bootstrap before any non-admin provisioning scripts.
- If the admin was deleted, re-bootstrap before adding users.
When it happens
Trigger: An attempt to register/create a normal (non-admin) account on a fresh installation that has no admin user yet.
Common situations: First-run registration submitted with isAdmin=false; a provisioning script that creates test users before bootstrapping the admin; DB reset that wiped the admin but the next request tries to add a non-admin.
Related errors
- Admin setup is not available
- Email is not available
- User does not exist
- User not found
- Admin status can only be changed by another admin
AI-assisted analysis of immich-app/immich@199723261c (2026-08-12).
Data as JSON: /api/errors/1a3c532eb0f9816c.
Report an issue: GitHub.