VibeFix

Guide

Could not find the table 'public.X' in the schema cache

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

Supabase's API (PostgREST) has no table by that name in its known tables. The table may never have been created in this project, the name in your code doesn't match, or the table lives in a schema the API doesn't expose. If the table does exist, run NOTIFY pgrst, 'reload schema'; in the SQL Editor to refresh the list.

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

Your app doesn't talk to Postgres directly. Calls like supabase.from('orders').select() go to PostgREST, which keeps a "schema cache": a snapshot of the tables, views and functions it is allowed to serve. When you ask for a table that isn't in that snapshot, it answers with HTTP 404 and error code PGRST205:

{
  "code": "PGRST205",
  "message": "Could not find the table 'public.orders' in the schema cache"
}

The name in quotes is what your code asked for, including the schema. That alone can tell you the cause.

Causes

CauseHow to tellFix
The table doesn't exist in this projectTable Editor doesn't list it, or step 1's query returns no rowCreate it (step 3) or run the missing migration
The app points at a different Supabase projectThe project ref in your app's Supabase URL differs from the dashboard you're looking atFix the URL and key in your env vars (step 2)
Name mismatch: typo, plural, or capitalsThe table is order but code asks for orders, or it was created as "Orders"Use the exact name in code (step 4)
The table is in another schemaStep 1 shows it under a schema other than public, or the error says 'public.x' but the table is in appExpose the schema and query it by name (step 5)
The cache is stale after a changeThe table exists in public with the right name, created minutes agoReload the cache (step 6)
Cache reloads aren't arrivingReload doesn't help, and logs show Failed listening for database notifications on the "pgrst" channelClear the notification queue (step 7)

How to fix it

1. Find out where the table really is. In the Supabase dashboard, open SQL Editor and run this (swap orders for your table name):

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

No rows means the table isn't in this project. A row shows the exact schema and spelling.

2. Check the app uses the same project. Your Supabase URL looks like https://abcdefgh.supabase.co. The abcdefgh part must match the project ref in your dashboard URL. Check the env vars where the app is deployed, not only locally. Names vary by setup, for example:

NEXT_PUBLIC_SUPABASE_URL=https://abcdefgh.supabase.co
VITE_SUPABASE_URL=https://abcdefgh.supabase.co

If the value is wrong, fix it and redeploy so the build picks it up.

3. Create the table if it's missing. If your project has a migrations folder (supabase/migrations), the table's SQL is probably there but was never applied. Run it in SQL Editor, or link the project and apply it with the CLI (replace abcdefgh with your project ref):

supabase link --project-ref abcdefgh
supabase db push --remote

Current CLI versions push to the local database unless you pass --remote. If your CLI is older and rejects --remote, run supabase db push after linking.

If there is no migration, create the table. Example, adjust columns to your app:

create table public.orders (
  id bigint generated always as identity primary key,
  user_id uuid references auth.users (id),
  total numeric not null,
  created_at timestamptz not null default now()
);

alter table public.orders enable row level security;

create policy "Users read their own orders"
on public.orders for select
to authenticated
using ((select auth.uid()) = user_id);
grant select, insert, update, delete on table public.orders to authenticated;
grant all on table public.orders to service_role;

Since 30 October 2026 new tables in public are not exposed to the API until you grant access. If you skip the grant, the API answers 42501 "permission denied for table" with a GRANT hint.

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

4. Make the name in code match exactly. Postgres folds unquoted names to lowercase. A table created as "Orders" (with quotes) is a different name from orders. Either match it in code:

const { data, error } = await supabase.from('Orders').select('*')

or rename it to lowercase, which is easier to live with:

alter table public."Orders" rename to orders;

Then search your code for every .from('...') call and check each name against step 1's result.

5. If the table is in another schema, expose it and ask for it by schema. In the dashboard, open the project's API settings (https://supabase.com/dashboard/project/_/settings/api) and add the schema to Exposed schemas. Then give the API roles access (replace myschema):

grant usage on schema myschema to anon, authenticated, service_role;
grant all on all tables in schema myschema to anon, authenticated, service_role;
grant all on all routines in schema myschema to anon, authenticated, service_role;
grant all on all sequences in schema myschema to anon, authenticated, service_role;
alter default privileges for role postgres in schema myschema
  grant all on tables to anon, authenticated, service_role;
alter default privileges for role postgres in schema myschema
  grant all on routines to anon, authenticated, service_role;
alter default privileges for role postgres in schema myschema
  grant all on sequences to anon, authenticated, service_role;

These grants give the roles table access; Row Level Security policies still decide which rows each user can read or change, so keep RLS on and add policies for these tables.

The first schema in the exposed list is the default. Requests without a schema go there, which is why you see 'public.x' when the table is elsewhere. Tell the client which schema to use, either for every query:

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.

const supabase = createClient(SUPABASE_URL, SUPABASE_KEY, {
  db: { schema: 'myschema' },
})

or for one query:

const { data, error } = await supabase
  .schema('myschema')
  .from('orders')
  .select('*')

6. Reload the schema cache. If the table exists in the right schema with the right name, PostgREST may not have picked it up yet. In SQL Editor run:

NOTIFY pgrst, 'reload schema';

You should see "Success. No rows returned". Try the app again.

7. If reloading doesn't take effect, refresh the notification queue. Supabase's troubleshooting guide gives this query for the case where PostgREST stops receiving reload signals:

select pg_notification_queue_usage();

Run it, then run step 6 again. No restart is needed.

Optional: reload automatically after every schema change. PostgREST's docs give an event trigger that sends the reload signal whenever you create or alter tables:

create or replace function public.pgrst_watch() returns event_trigger
  language plpgsql
  as $$
begin
  NOTIFY pgrst, 'reload schema';
end;
$$;

create event trigger pgrst_watch
  on ddl_command_end
  execute procedure public.pgrst_watch();

To remove it later: drop event trigger pgrst_watch;

How to check it's fixed

  1. Call the API directly, outside your app. Replace the project ref, table and key (use your anon or publishable key):
curl "https://abcdefgh.supabase.co/rest/v1/orders?select=*&limit=1" \
  -H "apikey: YOUR_ANON_KEY"

For a table in another schema, add -H "Accept-Profile: myschema".

  1. A JSON array (even []) means the API can see the table. PGRST205 means it still can't: go back to step 1.
  2. Load the page in your live app that failed before and confirm the data shows. An empty array with no error can mean RLS is hiding rows, which is a separate issue. If you now get permission denied for table, see our guide on Supabase permission denied for table (42501).

FAQ

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

Check the schema and spelling first (steps 1 and 4). If both are right, the API's cache is behind the database. Running NOTIFY pgrst, 'reload schema'; refreshes it.

Why does the error say 'public.X' when my table is in another schema?

Requests without a schema go to the first exposed schema, public by default. Set db: { schema: '...' } on the client or use .schema('...') on the query, and make sure that schema is in Exposed schemas.

It works in my preview but not in production. Why?

The two environments are probably using different Supabase projects, or production never got the migration. Compare the Supabase URL in each environment's env vars, then run step 1 in the production project.

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