Security basics
Supabase "Database error querying schema" when a user signs in
"Database error querying schema" means Supabase Auth could not read one user's row, usually one written by SQL. How to find the column and fix it.

In short
- "Database error querying schema" means Supabase Auth found the account and could not read its row in auth.users. The usual reason is an empty value, a NULL, where Auth expects text.
- It happens to accounts written into auth.users with SQL: a seed file, an import, or an insert an AI tool wrote. Accounts made by signing up through your app have no NULL there, which is why they still get in.
- The fix is one UPDATE that turns those NULLs into empty strings. Copy auth.users first, and make the next account through Supabase Auth rather than an insert.
Somebody tries to sign in to your app and the form answers with this:
Database error querying schema
It is not everybody. The people who signed up through your app last week get in as usual. What fails is one account, or a group of them: the admin account your AI tool set up for you, the test users from a seed file, the customers you moved across from another system. The password is right, and asking for a reset email for that address fails too.
Here is the part a search gets wrong: this message is about one person's row in one table, whatever the word "schema" suggests. It reads like the schema cache errors your tables can throw, so the results hand you the fixes for those: reload the cache, expose a schema in the API settings, restart the project. "Database error querying schema" comes from Supabase Auth, the part of Supabase that signs people in, and what it could not read is a single account.
What does "Database error querying schema" mean?
It means Supabase Auth found the account and could not read it.
When someone signs in with an email and a password, Auth first looks the
address up in auth.users, the table where Supabase keeps your accounts. Its
source code treats that lookup in two ways. If no row matches, the answer is
"Invalid login credentials", the same as a wrong password. If the database
reports any other error while reading the row, the answer is a 500 with this
sentence, and the body Auth sends back looks like this:
{"code":500,"error_code":"unexpected_failure","msg":"Database error querying schema"}
The sentence is the same whatever the error was, which is why it names nothing.
Supabase's troubleshooting note for this message gives the usual cause: the Auth
server has met NULL values in auth.users where it expects a string or an
empty string, and it usually happens after manual SQL inserts or updates to that
table.
Picture the register at a hotel's front desk. When the desk signs a guest in
itself, it fills every box on their line, and a box with nothing to say still
gets a short stroke to show it was left blank on purpose. A line added to the
register from outside the desk can leave a box untouched. The clerk reads the
whole line before looking at anything else, and an untouched box is the one
thing they have no rule for, so they stop and report a problem with the
register. In the database, an empty string is the short stroke and NULL is
the untouched box.
Where do you see the real error?
In the Auth logs, at the moment of the failed sign-in.
Sign in once as the account that fails, and note the time. In the Supabase dashboard, open Logs, then the Auth logs, and find the entry at that time. People who have reported this in public quote a line of this shape:
error finding user: sql: Scan error on column index 3, name "confirmation_token": converting NULL to string is unsupported
The name in quotes is the column. "Converting NULL to string is unsupported" is Auth saying it found an untouched box where it can only read text.
If the line names a table, a role or a permission rather than a NULL, read the section on other causes further down first, because the repair is different.
Why only some accounts get it
Because Auth reads one row per sign-in, and only the rows written by hand have the gaps.
Auth's source reads eight token and change columns of auth.users as plain
text, with no room for a NULL: the codes it sends for confirmation, password
recovery, email and phone changes and reauthentication, and the pending new
email and phone. When Auth creates an account itself, it writes an empty string
into each of them. Four of the eight have no default in Auth's own table
definition, so an insert that does not name them leaves them NULL:
confirmation_tokenrecovery_tokenemail_change_token_newemail_change
Those are the four an issue on Supabase Auth's own repository lists for this
exact error. The other four (email_change_token_current, phone_change,
phone_change_token and reauthentication_token) default to an empty string,
so they only end up NULL when an insert or an update sets them to NULL by name.
Supabase's note on the sign-up error names both ways such a row gets written:
users inserted directly with SQL, or by an AI tool that uses a direct SQL
INSERT. If you asked Lovable, Bolt, v0, Cursor, Claude Code or Replit for an
admin or test account and it answered with SQL, that is where your row came
from. A seed file does the same, and so does an import from another sign-in
system that writes into auth.users directly.
How do you fix "Database error querying schema"?
Fill the empty columns with empty strings, in one UPDATE, once you have a copy
of auth.users.
First, see which accounts are affected. In the SQL Editor:
select id, email, created_at
from auth.users
where confirmation_token is null
or recovery_token is null
or email_change_token_new is null
or email_change is null;
If the list is your admin account, your seed users or your import, you have
found it. If it comes back empty and the Auth log still names a column, add that
column to the where clause and run it again.
Before you change it, take a copy of that table. Supabase's Free plan keeps
no backups at all, and nothing in your app's code can rebuild auth.users: it
holds every account and every password hash. Exporting just the accounts is one
command, and
the post on getting your users into a dump
has it with the flags that matter.
Now the update:
update auth.users
set confirmation_token = coalesce(confirmation_token, ''),
recovery_token = coalesce(recovery_token, ''),
email_change_token_new = coalesce(email_change_token_new, ''),
email_change = coalesce(email_change, '')
where confirmation_token is null
or recovery_token is null
or email_change_token_new is null
or email_change is null;
coalesce(x, '') keeps whatever is in a box already and puts the short stroke
in an untouched one, so a row that was fine comes out exactly as it went in. It
is the statement in Supabase's own note, set <column_name> = '' where <column_name> is null, done for four columns at once. If your log named one of
the other four, add it in the same shape.
Last, sign in as one of those accounts. If the 500 comes back, read the Auth log again: the read stops at the first untouched box it meets, so a second one further along the row only shows up once the first is filled.
The account made in SQL has its password in a file
If the insert set a password, find out where that password is written down.
An insert into auth.users cannot ask Auth to hash a password, so the SQL does
it, with crypt('…', gen_salt('bf')) or something like it. The database keeps
only the hash. The text inside the first pair of quotes is the password as it
was typed, and it stays wherever that SQL was saved. When it was saved as a
migration, a file of SQL kept with your app's code, anyone who can read your
code can read that password. On a public GitHub repository, that is anyone.
So once the fix lets that account in, change its password through your app's own reset flow, which works again now that the row can be read. If it is an admin account, start there.
How to create the next account without this
Through Supabase Auth, which fills every column the way it later reads them.
There are two ways Supabase supports:
- In the dashboard. Authentication, then Users, then Add user and Create new user. Nothing to write and nothing saved in your code.
- From code.
supabase.auth.admin.createUser(), called with your secret key. Supabase's reference says this function should only be called on a server, and that you should never expose yourservice_rolekey in the browser.
The second one is where the next problem tends to start. An admin page that adds
users needs that key, and the quickest way for a builder to wire one up is in
the code your visitors' browsers download. A Supabase secret key (sb_secret_…,
or service_role in an older project) skips every row level security rule you
wrote, for whoever finds it.
Which keys belong in the browser, and which never do
is the post to read before you paste one, and
moving a secret into an edge function
is how the admin page keeps working without it.
If you would rather know than guess, our free scan reads your live app the way a stranger would and tells you whether a secret key is in the code it serves. It takes about 20 seconds and needs no account: scan your app.
Other causes, and how each one reads
The same sentence covers every database error during the lookup, so a log line without a NULL in it points to a different repair.
"Invalid login credentials" instead of the 500. Auth did not find the row at
all. Its lookup matches the email, an aud of authenticated and an
instance_id of all zeros, and a hand-written row that left either of the last
two empty is invisible to it.
"Invalid login credentials" has its own post for
the ordinary causes.
A permission or a missing table in the log line. Something has changed what
Auth's own database role can reach in the auth schema, or a table Auth expects
there is missing. Supabase's note on the sign-up error names Prisma as one tool
that can break the permissions on auth.users. That is not a gap to fill in,
and the log line is what to send to Supabase support.
"Unable to process request" on the reset form. The same broken row, met through the password reset. The update above clears both.
Keeping a copy of your accounts before you edit them
Take one before every change you make to auth.users by hand, and keep it where
the SQL Editor cannot reach it.
Reeve Care keeps a copy of your Supabase database, accounts included, outside your Supabase account.
- an encrypted copy on a schedule, kept on Reeve's own storage in the EU
- the
authschema in every copy, so the rows you are about to edit exist somewhere your SQL cannot touch - each copy verified before it counts, by counting the rows in every table
- a one-click restore for your own tables, with a safety copy of what is there now taken first, and a person to put accounts back from the copy when you need them
- your uploaded files as well, once you connect a Storage credential
Our free scan checks the code your app serves for a Supabase secret key.
- a
service_roleorsb_secret_…key in the browser, told apart from the publishable key that belongs there - whether a stranger with no account can read your tables
- nine checks in about 20 seconds, with no account to create
What to do today
What to do
- Sign in once as the account that fails, then read the Auth log entry at that time. The column it names is your answer.
- Run the select above to list every account with a NULL in those four columns.
- Export
auth.usersbefore you change anything in it. - Run the one update, then sign in as one of the accounts it touched.
- If a migration set that account's password, change the password now.
- Make the next account from Authentication, Users, Add user, or with
auth.admin.createUser()on a server.
Start with the account you made for yourself, because an admin is the one whose password matters most if it is sitting in a file. If it is sign-up that fails rather than sign-in, the message is "Database error saving new user", and it has a repair of its own.
FAQ
What does "Database error querying schema" mean in Supabase?
It means Supabase Auth looked up the person signing in, found their row in auth.users, and got an error from the database while reading it. Auth answers with this one sentence and a 500 for any database error during that lookup, except "no such user", which gets "Invalid login credentials". The usual error underneath is a NULL in a column Auth reads as text, and the Auth log line names the column.
Why can some users sign in and others get this error?
Because Auth reads one row per sign-in, and only some rows have the gap. When Supabase Auth creates an account itself it writes an empty string into its token columns, so accounts made by signing up have no NULLs there. An SQL insert that does not name four of those columns leaves them NULL, because Auth gives them no default: confirmation_token, recovery_token, email_change_token_new and email_change.
Is it safe to run an UPDATE on auth.users?
This one changes nothing but the empty columns: coalesce keeps every value already there and turns a NULL into an empty string, which is what Auth itself would have written. It is still the table that holds every account in your app, and the Supabase Free plan keeps no backup of it, so export it first. A mistake in an UPDATE on that table cannot be undone without a copy.
How should I create users in Supabase instead of an SQL insert?
Through Supabase Auth, which fills every column the way it later reads them. In the dashboard that is Authentication, then Users, then Add user and Create new user. From code it is supabase.auth.admin.createUser(), which needs your secret key, and Supabase says to call it only on a server and never to expose the service_role key in the browser.
Why does a wrong password give the same error?
Because Auth reads the account before it checks the password. The lookup by email fails on the broken row, so the request ends there with a 500 whatever was typed into the password box. An email address with no account at all gets "Invalid login credentials" instead.