Errors creating, updating or deleting users

Fix "Database error creating new user", "Database error deleting user" and similar errors in Studio's Auth users page or the admin API. Usually a trigger or a foreign key.

What you see

In Studio's Authentication users page, or from the admin API (auth.admin.createUser, updateUserById, deleteUser), one of:

Database error creating new user
Database error saving new user
Database error updating user
Database error deleting user
A user with this email address has already been registered
Password should be at least 8 characters.

Why it happens

Error Usual cause
Creating or saving a new user A trigger on auth.users fails on insert, often the one that creates a profile.
Updating a user An on update trigger on auth.users fails, or a column it writes has a constraint.
Deleting a user A row in your tables references the user with a foreign key that has no on delete action, so Postgres refuses the delete.
Already registered That email belongs to another user, possibly an unconfirmed one you created earlier.
Password too short The password is shorter than the project's Minimum password length. The admin API enforces it too.

How to fix it

Open Studio's SQL editor (Dashboard → your project → Database tab → Open Studio).

  1. For create and update errors, check the triggers:

    select tgname, pg_get_triggerdef(oid) as definition
    from pg_trigger
    where tgrelid = 'auth.users'::regclass and not tgisinternal;
    

    Reproduce and fix the failing function as described in Database error saving new user.

  2. For delete errors, find what references the user:

    select conrelid::regclass as referencing_table,
           conname as constraint_name,
           pg_get_constraintdef(oid) as definition
    from pg_constraint
    where contype = 'f' and confrelid = 'auth.users'::regclass;
    

    Then decide what should happen to that data when a user goes. Delete it with them:

    alter table public.profiles
      drop constraint profiles_id_fkey,
      add constraint profiles_id_fkey
        foreign key (id) references auth.users (id) on delete cascade;
    

    Or keep it and clear the link, which suits records like invoices you must retain:

    alter table public.invoices
      drop constraint invoices_created_by_fkey,
      add constraint invoices_created_by_fkey
        foreign key (created_by) references auth.users (id) on delete set null;
    

    on delete set null needs the column to allow nulls.

  3. For "already registered", look the address up:

    select id, email, email_confirmed_at, created_at, is_anonymous
    from auth.users
    where lower(email) = lower('[email protected]');
    

    Delete the stale user or update the existing one instead of creating a new one.

  4. For password errors, use a longer password, or change Minimum password length under Auth tab → Sign-in & security (6 to 72).

On SupaHost

  • If Studio's message is vague, try the same action from a server script with the admin API and log the whole error object, including code and status.
  • Only the instance owner can open Studio or reveal the service_role key. Team members see the project read-only.
  • Disable new sign-ups stops public sign-ups. Creating users with the admin API still works.
  • On Business and Enterprise, sudo supahost-logs app-one auth over SSH shows the database error behind the message.

Updated 11 November 2026 · View as Markdown · Something wrong or missing? Tell us