Blog ·

Sign-up fails with "Database error saving new user"? Check your Supabase trigger

You built your app with Lovable, Bolt, Cursor or Replit, with Supabase handling sign-up. It worked when you tested it. Now a new user fills in the form, presses sign up, and nothing happens, or the app shows "Database error saving new user". No account is created.

This often starts after you, or your AI tool, added a feature: a profiles table, a role, a team, a username field. The sign-up form did not change, so it is easy to miss.

The short answer

Most AI-built apps copy each new user into their own table, usually public.profiles, with a database trigger on auth.users. Supabase's docs show this pattern and warn: "If the trigger fails, it could block signups, so test your code thoroughly."

That is exactly what this error means. Supabase's troubleshooting guide for "Database error saving new user" lists the common causes as a trigger or trigger function on auth.users that has an error, a constraint on auth.users that isn't being met, and Prisma having broken the permissions on auth.users. When the trigger fails, the whole sign-up is rolled back, so the user is not created either. Supabase's error code docs describe a 500 error from Auth as most often pointing to a problem in your database setup, such as a misbehaving trigger.

Find the real error

The message on screen is generic. The logs say what actually went wrong. Supabase's guide recommends two steps:

  1. Check the Auth logs. In your Supabase project dashboard, open the Auth logs explorer and find the failed sign-up. It usually shows the specific database error.
  2. Check the Postgres logs. If the Auth logs point at the database, open the Postgres logs explorer. The matching error often names the function and line, for example PL/pgSQL function public.handle_new_user() line 3 at SQL statement.

Then match what you see below.

Common causes and fixes

  • relation "profiles" does not exist. The trigger function inserts into a table that was never created or was dropped. Supabase's guide says to create the table if it should exist, or update or remove the reference in the function if it isn't needed. You can view and edit functions on the Database Functions page in the dashboard.
  • The function's table name has no schema. Supabase's example function sets security definer set search_path = '', which means every table inside it must be written with its schema, as public.profiles, not just profiles. If your AI tool wrote profiles without public., the trigger can fail with the same "does not exist" error even though the table is there.
  • A column the trigger fills in doesn't match. If the function inserts a column that was renamed, or the table has a required (NOT NULL) column the trigger doesn't fill, every sign-up fails. This often happens when the form stops sending a field, such as a name, that the trigger reads from the user's metadata (raw_user_meta_data). Make that column optional or give it a default, or change the function so it handles a missing value.
  • A constraint on auth.users. If a constraint was added to Supabase's own users table and a new user doesn't meet it, sign-up fails. Supabase manages the auth schema, so it is safer to drop that constraint and enforce the rule in your own tables instead.
  • Users added by SQL, not by the sign-up flow. Supabase's guide also covers errors like converting NULL to string is unsupported on a column such as confirmation_token. It says this typically happens when users are inserted directly with SQL, sometimes by an AI tool, instead of through the Auth API, and gives this fix for the column named in your error:
update auth.users
set confirmation_token = ''
where confirmation_token is null;

Check it worked

Sign up on your live site with an email address you have never used in the app. The new user should appear in your Supabase project's list of users, and a matching row should appear in your profiles table. Your own old account will not show this problem, because it was created before the trigger changed.

Paste this into your AI tool

> New users get "Database error saving new user" when they sign up. Please find every trigger on auth.users and the function each one calls (often public.handle_new_user). Check that every table it writes to exists, that every table name includes its schema (for example public.profiles) since the function uses search_path = '', and that every NOT NULL column it inserts has a value even when the user's metadata is missing that field. Show me the fixed function as SQL before running it. Do not add constraints to auth.users and do not insert users into auth.users directly with SQL.

Catch it before your users do

This kind of break is easy to miss because your own login keeps working. Scheduled testing from FlowCanary is launching by 30 November 2026. Once it is live, it will test the flows a new visitor can do in your app, such as sign-up and checkout, in a real browser on a schedule, with logged-in flows on Pro, and tell you in plain English when one breaks, with a fix prompt for Lovable, Bolt, Cursor or Replit. Until then, the free check works today: paste your live URL and it opens the page in a real browser and reports JavaScript errors, failed requests and blank pages.

Run the free checker