# Supabase "Database error saving new user": causes and how to fix it

Source: https://vibe-fixer.com/guides/supabase-database-error-saving-new-user
Last updated: 2026-11-26

**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](https://vibe-fixer.com/): 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.users` fails.
- A common cause is a broken trigger, for example one that copies new users into a `profiles` table.
- 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 `public` schema 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.

Login, emails or payments broke in your live app? Our AI agent fixes it in your code, then tests your live app again.

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](https://supabase.com/kb/troubleshooting/database-error-saving-new-user-RU_EwB)).

**Something broke on your live app?** Tell us what broke. Our AI agent tries it on your live app and sends you a screenshot, free. [Check my app free](https://vibe-fixer.com/?src=guide-supabase-database-error-savi-t#triageForm)

## 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](https://supabase.com/docs/guides/auth/debugging/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](https://supabase.com/docs/guides/auth/managing-user-data))

## 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**

1. In the Supabase dashboard, open the Auth logs and find the failed sign-up.
2. If it points to the database, open the Postgres logs at the same time and read the error line.
3. Match it to a cause below.

Source: [Supabase troubleshooting: Database error saving new user](https://supabase.com/kb/troubleshooting/database-error-saving-new-user-RU_EwB)

### 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**

1. If the table should exist in the `public` schema, create it.
2. 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](https://supabase.com/kb/troubleshooting/database-error-saving-new-user-RU_EwB)

### 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**

1. Read the Postgres error line to see which statement failed.
2. Compare the function with Supabase's reference version: it is declared `security definer set search_path = ''`, writes to the fully named table `public.profiles`, and reads optional fields from `new.raw_user_meta_data`.
3. Make every column the function fills either optional or always provided by your sign-up form.
4. Test by signing up a new address, then check that the profile row appears.

5. To list the triggers on `auth.users`, run this in the SQL editor and check the function each one calls:

```sql
select tgname, tgfoid::regproc as function_name
from pg_trigger
where tgrelid = 'auth.users'::regclass and not tgisinternal;
```

Source: [Supabase: User management](https://supabase.com/docs/guides/auth/managing-user-data)

### 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**

1. Look in the Postgres logs for the failing constraint.
2. 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](https://supabase.com/kb/troubleshooting/database-error-saving-new-user-RU_EwB)

### 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**

1. 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;`
2. Create users through the Auth API from now on, not with direct inserts.

Source: [Supabase troubleshooting: Database error saving new user](https://supabase.com/kb/troubleshooting/database-error-saving-new-user-RU_EwB)

### 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**

1. Check the Postgres logs for errors on the auth schema.
2. Keep tools that manage your own tables away from the `auth` schema.

Source: [Supabase troubleshooting: Database error saving new user](https://supabase.com/kb/troubleshooting/database-error-saving-new-user-RU_EwB)

**App broke after you published it?** Our AI agent fixes it in your code, then tests your live app again so you see the result yourself. The first check is free. [Check my app free](https://vibe-fixer.com/?src=guide-supabase-database-error-savi-m#triageForm)

### 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.

```sql
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:

```sql
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?

1. 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.
2. Check that the sign-up goes through and that the profile row appears.
3. 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](https://community.weweb.io/t/supabase-auth-500-error-database-error-saving-new-user/7248) 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](https://vibe-fixer.com/pricing).

## Related guides

- [TypeError: Failed to fetch in Supabase apps: fix](https://vibe-fixer.com/guides/supabase-typeerror-failed-to-fetch)
- ["new row violates row-level security policy"](https://vibe-fixer.com/guides/data-wont-save-row-level-security)
- [Supabase "permission denied for table" (42501)](https://vibe-fixer.com/guides/supabase-permission-denied-for-table-42501)
- [Supabase "Error sending confirmation email" (500)](https://vibe-fixer.com/guides/supabase-error-sending-confirmation-email)
- [Sign-up or login broken after publishing](https://vibe-fixer.com/guides/login-broken-after-publish)
- [The AI says it fixed it, but my app is still broken](https://vibe-fixer.com/guides/vibe-coding-expert)
- [Database error querying schema (Supabase Auth 500)](https://vibe-fixer.com/guides/supabase-database-error-querying-schema)

## Sources (official documentation)

- [Supabase troubleshooting: Database error saving new user](https://supabase.com/kb/troubleshooting/database-error-saving-new-user-RU_EwB)
- [Supabase: User management (profiles table and trigger)](https://supabase.com/docs/guides/auth/managing-user-data)
- [Supabase: Auth error codes (500 and database triggers)](https://supabase.com/docs/guides/auth/debugging/error-codes)
- [Supabase: Row Level Security](https://supabase.com/docs/guides/database/postgres/row-level-security)
- [Supabase: signUp in auth-js (source)](https://github.com/supabase/auth-js/blob/master/src/GoTrueClient.ts)

## 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.

VibeFix's free check tries the problem you describe on your live app: tell us what broke, and our AI agent tries it and sends you a screenshot. If you want it fixed, it finds the cause, fixes it in your code and re-checks your live app. The free check never changes your app and never emails your users. [Check my app free](https://vibe-fixer.com/?src=guide-supabase-database-error-savi-f#triageForm)

Related: [Fix 42501 tool](https://vibe-fixer.com/tools/fix-42501) · [Supabase RLS policy generator](https://vibe-fixer.com/tools/rls-policy-generator) · [Supabase "Email not confirmed" error](https://vibe-fixer.com/guides/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
