Guide
Supabase "Database error saving new user": causes and how to fix it
Still failing on your live site? Check it free ↓
Updated
Short answer: Supabase shows "Database error saving new user" when something that runs inside the database while a new user is saved to auth.users fails. A common cause is a broken trigger, for example one that copies new users into a profiles table. Read the Auth logs, then the Postgres logs, and fix the trigger, table or constraint they name.
Seeing this on your live site, and you don't write code? Run the free check: our AI agent signs up to your live app as a brand-new person, tries the step that fails and sends you a screenshot of what it hit. If you want it fixed, it finds the cause, fixes it in your code and re-checks your live app.
Key takeaways
- Supabase shows "Database error saving new user" when something that runs inside the database while a new user is saved to
auth.usersfails. - A common cause is a broken trigger, for example one that copies new users into a
profilestable. - Read the Auth logs first, then the Postgres logs, and fix the trigger, table or constraint they name.
- If a trigger writes to a table that does not exist, create the table in the
publicschema or remove the reference in the function. - Sign-up can work for you and fail for a new person, because the trigger only fires for a brand-new user.
A new person signs up and gets "Database error saving new user". The account is not created and they cannot get in. Supabase has an official troubleshooting page with this exact title (Database error saving new user).
What does "Database error saving new user" mean in Supabase?
It means the database refused to save the new user. Supabase says the error is normally a side effect of a database transaction: something that runs inside the database when a new row is added to auth.users fails, and the user is not saved. Its error reference adds that a 500 from Auth "most often" points to the database setup, "such as a misbehaving trigger" (Supabase: Auth error codes).
The first common cause Supabase lists is a trigger on auth.users that has an error, such as one that copies each new user into a profiles table. Supabase's own guide warns: "If the trigger fails, it could block signups, so test your code thoroughly." (Supabase: User management)
What causes "Database error saving new user", and how do I fix each cause?
The causes on this page are a trigger that writes to a table that does not exist, a trigger function that errors, a constraint on the users table that is not met, users inserted directly with SQL or by an AI tool, a tool that changed the permissions on the users table, and a profile save that row-level security rejects right after sign-up.
Supabase's debugging order is: Auth logs first, then the Postgres logs.
0. How do I find the real error behind "Database error saving new user"?
Open the Auth logs in the Supabase dashboard, find the failed sign-up, and if it points to the database, read the error line in the Postgres logs.
The message on screen is generic. The database log is not.
How to fix it
- In the Supabase dashboard, open the Auth logs and find the failed sign-up.
- If it points to the database, open the Postgres logs at the same time and read the error line.
- Match it to a cause below.
Source: Supabase troubleshooting: Database error saving new user
1. Why does sign-up fail when the trigger writes to a table that does not exist?
The trigger function inserts into a table that was never created or was accidentally dropped. The Postgres log shows a "relation ... does not exist" message, for example for profiles, and the function is often handle_new_user.
How to fix it
- If the table should exist in the
publicschema, create it. - If it is not needed, open Database Functions in the dashboard and update or remove the reference in the function.
Source: Supabase troubleshooting: Database error saving new user
2. Why does sign-up fail when the trigger function itself errors?
Whatever error the function hits makes the sign-up fail with it. Supabase lists "a trigger/trigger function setup on the auth.users table that has an error" as a cause.
How to fix it
- Read the Postgres error line to see which statement failed.
- Compare the function with Supabase's reference version: it is declared
security definer set search_path = '', writes to the fully named tablepublic.profiles, and reads optional fields fromnew.raw_user_meta_data. - Make every column the function fills either optional or always provided by your sign-up form.
- Test by signing up a new address, then check that the profile row appears.
- To list the triggers on
auth.users, run this in the SQL editor and check the function each one calls:
select tgname, tgfoid::regproc as function_name
from pg_trigger
where tgrelid = 'auth.users'::regclass and not tgisinternal;
Source: Supabase: User management
3. Why does sign-up fail when a constraint on the users table is not met?
A constraint added on auth.users rejects the new row. Supabase lists a constraint that is not being met as a cause.
How to fix it
- Look in the Postgres logs for the failing constraint.
- Remove or relax a constraint you added yourself, or make the sign-up provide the value it needs.
Source: Supabase troubleshooting: Database error saving new user
4. Can users inserted directly with SQL or by an AI tool cause this error?
Yes, though it is a related error: Supabase lists direct SQL inserts on the same page, but its example error reads "Database error querying schema".
Auth expects empty strings in some columns. Users added with a direct SQL INSERT, rather than through the Auth API, can leave them NULL, and the error names the column, for example with "converting NULL to string is unsupported."
How to fix it
- Run Supabase's fix in the SQL editor, using the column the error names:
update auth.users set confirmation_token = '' where confirmation_token is null; - Create users through the Auth API from now on, not with direct inserts.
Source: Supabase troubleshooting: Database error saving new user
5. Can a tool that changed the permissions on the users table cause this error?
Yes: Supabase lists Prisma breaking the permissions on auth.users as a known cause.
How to fix it
- Check the Postgres logs for errors on the auth schema.
- Keep tools that manage your own tables away from the
authschema.
Source: Supabase troubleshooting: Database error saving new user
6. Sign-up works, but saving the profile right after fails with "new row violates row-level security policy"
This is the case where the app, not a trigger, writes the profile row just after sign-up. Sign-up itself succeeds; the second request is rejected by row-level security on the profiles table. Row-level security runs inside the database on every access. For an insert, the rule has to confirm the new row belongs to the person making the request; with it on and no matching rule, the row is rejected.
Check: the error text is "new row violates row-level security policy" (code 42501), not "Database error saving new user", and it appears on the profile save, not on sign-up. The possible causes:
- The profiles table has row-level security on, but no insert rule that lets a new user write their own row.
- The row is written with a different or empty user ID than the signed-in user's.
- The save runs before the person is signed in: if email confirmation is on, signUp returns no session, so a save made right after sign-up has no signed-in user.
Fix, option 1: create the profile in the database with the trigger from Supabase's user-management guide (the reference version described in cause 2), and remove the profile insert from the sign-up code.
create function public.handle_new_user()
returns trigger
language plpgsql
security definer set search_path = ''
as $$
begin
insert into public.profiles (id)
values (new.id);
return new;
end;
$$;
create trigger on_auth_user_created
after insert on auth.users
for each row execute procedure public.handle_new_user();
Adapt the columns to your profiles table. Test it after the change: Supabase warns that a failing trigger can block sign-ups.
Fix, option 2: keep the save in the app. This assumes the profile's id column holds the signed-in person's user ID. Add a rule that lets a signed-in person insert only their own row, plus a read rule so the app can read the profile afterwards:
create policy "Users can create their own profile"
on profiles for insert to authenticated
with check ( (select auth.uid()) = id );
create policy "Users can read their own profile"
on profiles for select to authenticated
using ( (select auth.uid()) = id );
Run the save only after sign-in has a session. If email confirmation is on, save the profile after the first sign-in, or use option 1.
Do not turn row-level security off to make the error go away. Supabase says to "Enable RLS on every table in an exposed schema."
Why does sign-up work for me but fail for a new person?
Your own account already exists, so you never run the trigger again, and it only fires for a brand-new person.
You're signed in, your customers aren't. Your own account already exists, so you never run the trigger again. It only fires for a brand-new person, which is exactly who meets the error.
How do I check it's fixed?
- Open your live app in a private (incognito) window and try it as a new user: sign up with an address that has never been used.
- Check that the sign-up goes through and that the profile row appears.
- Open the Auth logs and the Postgres logs in the Supabase dashboard and check that the error no longer appears for that sign-up.
Frequently asked questions
It worked until I added a profiles table. What broke?
Most likely the trigger function that writes new users to your profiles table. In one reply on a WeWeb community thread about a 500 on sign-up, the cause was an error in a trigger function that wrote new users to a public table. Read the Postgres log line, then fix the function or the table (causes 1 and 2).
Does this error mean the email or the password is wrong?
No. It is raised by the database while saving the new user. Nothing the person types fixes it; the fix is in your project.
I get it when I invite a user from the dashboard. Same cause?
Yes. Supabase's troubleshooting page says the error often appears when inviting a user from the dashboard or inserting one in the table editor. The same trigger runs for every new user.
Can VibeFix fix it for me?
Yes, for any app whose code is on GitHub, whichever tool built it (Lovable, Bolt, Base44, Replit, v0, Cursor). The free check confirms the problem on your live app first. If you want it fixed, our AI agent finds the cause, fixes it in your code for $29 and tests your live app again. See pricing.
Related guides
- TypeError: Failed to fetch in Supabase apps: fix
- "new row violates row-level security policy"
- Supabase "permission denied for table" (42501)
- Supabase "Error sending confirmation email" (500)
- Sign-up or login broken after publishing
- The AI says it fixed it, but my app is still broken
- Database error querying schema (Supabase Auth 500)
Sources (official documentation)
- Supabase troubleshooting: Database error saving new user
- Supabase: User management (profiles table and trigger)
- Supabase: Auth error codes (500 and database triggers)
- Supabase: Row Level Security
- Supabase: signUp in auth-js (source)
Fixed it? Prove it works on your live app
After the fix, the proof is a brand-new address signing up and getting in, with its profile row created. Your own account cannot show that, because it is not new. Your AI fixed it. VibeFix proves it works on the live site.
Related: Fix 42501 tool · Supabase RLS policy generator · Supabase "Email not confirmed" error
VibeFix is independent. Supabase, Prisma, Lovable, Bolt and Base44 are trademarks of their owners.
Want it fixed for you? For any app whose code is on GitHub, whichever tool built it, VibeFix's AI agent can find the cause of this error, fix it in your code and re-check your live app. Start with a free check: https://vibe-fixer.com
Still seeing this error? Get it fixed, starting with a free check ↑
How this guide was made: Written with AI assistance and checked against the sources linked on this page.
More guides · Videos · Use VibeFix in Claude Code · Shopify store accessibility · About · Your privacy choices