how do i create a new superadmin on an existing server that has lost all superadmins
I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.
Here is the recovery procedure for a server that has lost all superadmin access:
Regain access using the Recovery Administrator
The built-in mechanism for this exact situation is the STALWART_RECOVERY_ADMIN environment variable. It creates a temporary bypass credential that works even when the directory has no admin accounts left.
Step 1 - Set the environment variable before starting (or restarting) Stalwart:
STALWART_RECOVERY_ADMIN=admin:yourchosenpasword
This account bypasses the directory entirely, so it works regardless of what is in the database.
Step 2 - Log in with those credentials via the WebUI or CLI and either:
Promote an existing user account to administrator by assigning it the appropriate admin Role and permissions, or
Create a brand-new account and assign it admin permissions.
Step 3 - Remove the variable once you are done. The docs are explicit about this:
STALWART_RECOVERY_ADMIN must not be left permanently set on a production deployment. It is a backdoor credential intended to rescue a server that has lost normal access, not a primary login.
Restart the server without the variable set to return to normal operation.
Note: If you also need to stop mail processing during the recovery work, you can combine this with STALWART_RECOVERY_MODE=1, which disables all background services and only exposes the management HTTP endpoint on port 8080.