VibeFix

Guide

42P01: relation does not exist

Published by Yosef D., founder of VibeFix

How this guide was made: Written with AI assistance and checked against the sources linked on this page.

Updated

Short answer: Postgres can't find the table, view or sequence your query names. In a Supabase app this can mean the table was never created in this project (a migration that never reached production), it sits in a schema other than public, or its name differs in spelling or capitals. Find which, then fix the name or create the table.

Get it fixed: a free check first confirms the problem on your live app, usually in 4 to 10 minutes.

Free. No account needed. It usually takes 4 to 10 minutes.

Want it fixed? Our AI agent fixes it in your code for $79 and tests your live app again. If we can't complete your re-check, you get your money back.

What it means

42P01 is the Postgres error code undefined_table. The full message names the object it looked for, for example:

ERROR: 42P01: relation "profiles" does not exist

"Relation" is the Postgres word for a table, view or sequence. The quoted name is your first clue: it tells you exactly what Postgres searched for, in which form. Postgres doesn't guess. If the name, the schema or the capital letters don't match an existing object, the query stops with this error.

You can see it in the Supabase SQL Editor, in your app's network responses, in the Postgres logs, or inside a function or trigger, where it can break something that looks unrelated, such as sign-up.

Causes

CauseHow to tellFix
The table doesn't exist in this projectThe check query in step 1 returns no rows. Can happen when the app works in one project (dev, preview) and fails in another (production).Run the missing migration on that project, or create the table (steps 2-3).
The table is in another schemaStep 1 finds it, but table_schema is not public.Name the schema: .schema('name') in supabase-js, or schema.table in SQL (step 4).
Capital letters or a typoStep 1 finds a name like Profiles or user_profile while your code asks for profiles.Rename the table to lowercase, or make the code match exactly (step 5).
A function or trigger uses an empty search pathThe error appears during sign-up, an RPC call or an insert, and the function has set search_path = ''.Write public.table_name everywhere inside the function body (step 6).
The table was dropped or renamedIt existed before; your migration history shows a drop table or rename.Restore it with a new migration, or update the code to the new name.

Fix it step by step

1. Find out whether the table exists, and where. Open the SQL Editor in the Supabase dashboard of the project that throws the error (check the project URL in your app's env vars, so you're looking at the right one). Replace profiles with the name from your error:

select table_schema, table_name
from information_schema.tables
where table_name ilike 'profiles';

2. If you use the Supabase CLI, check whether a migration is missing. From your project folder:

supabase link
supabase migration list --remote

supabase link asks you to pick the project. The list shows which migrations are applied locally and on the remote project. A migration that is local only is your gap. Push it:

supabase db push --remote

3. If you don't use migrations, create the table directly. Copy the create table statement from the project where the app works (or from the SQL your builder generated), and run it in the SQL Editor of the broken project. Example:

create table public.profiles (
  id uuid primary key references auth.users (id) on delete cascade,
  full_name text,
  created_at timestamptz not null default now()
);

alter table public.profiles enable row level security;
grant select, insert, update, delete on table public.profiles to authenticated;
grant all on table public.profiles to service_role;

Since 30 October 2026 Supabase no longer gives the API roles access to new tables in public by default, so a table you create now needs these grants before your app can read it. Row-level security still decides which rows each user sees.

Source: Supabase changelog: tables not exposed to the Data API automatically

Then add the same RLS policies the working project has. A new table with RLS on and no policies returns no rows to your app.

4. If the table is in another schema, name the schema. In supabase-js:

const { data, error } = await supabase
  .schema('app')
  .from('profiles')
  .select('*');

In SQL:

select * from app.profiles;

Get it fixed: a free check first confirms the problem on your live app, usually in 4 to 10 minutes.

Free. No account needed. It usually takes 4 to 10 minutes.

Want it fixed? Our AI agent fixes it in your code for $79 and tests your live app again. If we can't complete your re-check, you get your money back.

If this then returns 42501 permission denied, the custom schema also has to be added to the exposed schemas in your project's API settings. Supabase-managed schemas such as auth and vault can't be read through the API directly. Use a security definer function for that data.

5. If the name has capitals or a typo, make them match. A table created with quotes, like "Profiles", is case-sensitive, and an unquoted profiles won't find it. The simplest fix is to rename it to lowercase:

alter table "Profiles" rename to profiles;

Then search your code for every reference to the old name and update it. If you'd rather keep the name, query it with the exact capitals, in quotes in SQL (select * from "Profiles";).

6. If the error comes from a function or trigger, add the schema to every table name. A security definer function must set a search_path, and Supabase's examples use search_path = ''. With an empty search path every table must be written with its schema. One case is the trigger that creates a profile row at sign-up:

create or replace function public.handle_new_user()
returns trigger
language plpgsql
security definer
set search_path = ''
as $$
begin
  insert into public.profiles (id, full_name)
  values (new.id, new.raw_user_meta_data ->> 'full_name');
  return new;
end;
$$;

Here insert into profiles would fail with 42P01. insert into public.profiles works. To find functions that mention the table:

select n.nspname as schema_name, p.proname as function_name
from pg_proc p
join pg_namespace n on p.pronamespace = n.oid
where n.nspname = 'public'
  and p.prokind in ('f', 'p')
  and pg_get_functiondef(p.oid) ilike '%profiles%';

Open each one, add public. in front of each table name, and run the create or replace again.

How to check it's fixed

  1. Run the step 1 query again. It should return one row, in the schema and with the exact name your code uses.
  2. Run the same query your app runs, in the SQL Editor, for example select * from public.profiles limit 1;. No error means Postgres finds it.
  3. Repeat the action that failed in the live app (sign up, load the page, save the form) with the browser's network tab open. The request should return 200 or 201, with no 42P01 in the response.
  4. If the error came from a function, check the Postgres logs in the dashboard after your test. No new relation ... does not exist entries means the function now finds the table.

FAQ

Why does the app work in preview but not in production?

The two can point at different Supabase projects, or at the same project before and after a change. The table exists where the app works and is missing where it fails. Compare the Supabase URL in each environment, then run the missing migration or create table on the production project.

I can see the table in the Table Editor. Why does Postgres say it doesn't exist?

Check three things: the schema shown in the Table Editor's schema picker, the exact capitals of the name, and whether the failing query runs inside a function with search_path = ''. Any of these makes a visible table invisible to that one query.

Is 42P01 the same as 42501 permission denied?

No. 42P01 means Postgres can't find the table at all. 42501 means it found the table but the role running the query isn't allowed to use it. Fixing the schema name can turn the first into the second, which is a step forward: the next fix is grants or the exposed-schemas setting.

Can VibeFix fix it for me?

Yes, for apps built in Lovable or any app whose code is on GitHub. 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 $79 and tests your live app again. See pricing.

Sources

Last checked: 16 November 2026.

VibeFix is independent. Supabase is a trademark of its owner.

Want it fixed?

Our AI agent fixes it in your code for $79 and tests your live app again. If we can't complete your re-check, you get your money back.

It starts with a free check that confirms the problem on your live app, no account needed.

Check my app free

More guides · Shopify store accessibility · About · Your privacy choices