Supabase "Could not find the table in the schema cache": PGRST205 and PGRST204 explained
By AI App Medic · Updated · Supabase · PostgREST · Migrations · Lovable
Your app loads, the console fills with red, and the Network tab shows a failed request to /rest/v1/ with a body like one of these:
{"code":"PGRST205","details":null,"hint":null,"message":"Could not find the table 'public.invoices' in the schema cache"}
{"code":"PGRST204","details":null,"hint":null,"message":"Could not find the 'due_date' column of 'invoices' in the schema cache"}
In supabase-js the same text shows up in error.message. These two codes come from PostgREST, the service behind the Supabase Data API. Its error reference describes PGRST205 as "the table specified in the URI is not found" and PGRST204 as "the column specified in the columns query parameter is not found". The wording "schema cache" scares people into thinking something is broken on the server. Most of the time nothing is broken: the code is asking for something that is not where it expects.
This is a common one in Lovable, Bolt and Cursor projects, because the AI writes the front end code and the SQL migration as two separate steps. When they drift apart, the code asks for a table or column the database does not have yet. Work through the checks below in order. Reloading the cache is the last step, not the first.
Step 1: read the code and the name
Copy the name in quotes exactly. For PGRST205 it includes the schema, for example public.invoices. PostgREST sometimes adds a suggestion in the response when a similarly named table exists, along the lines of "Perhaps you meant the table 'public.invoices'". If you see that, you have a typo and you are done.
If you do not see a suggestion, run this in the SQL Editor of the project you think you are using and see whether the table exists at all:
select table_schema, table_name
from information_schema.tables
where table_name ilike '%invoice%';
-- for PGRST204, check the column
select column_name, data_type
from information_schema.columns
where table_schema = 'public' and table_name = 'invoices';
The result sorts you into one of four cases below.
Case 1: the name does not match
PostgREST matches names exactly. Things that look identical to a human but are not:
invoiceversusinvoices.dueDatein the code versusdue_datein Postgres. AI tools like camelCase, Postgres columns are usually snake_case.- A table created in the dashboard or a migration with quotes and capital letters, for example
create table "Invoices" (...). From then on it must be quoted in SQL, and the REST path has to beInvoiceswith the same capital. Renaming it to lowercase is simpler:
alter table "Invoices" rename to invoices;
Fix the name in the code or the database, whichever is wrong, and keep both sides in sync. If you rename a column, update every .select(), .insert() and generated type that mentions it.
Case 2: the migration never ran in this project
This is the most common real cause. The table exists in a Supabase project, just not the one your app is calling. It happens when:
- The migration ran on your local stack or a preview branch, but production never got it.
- You moved the app off a builder's managed backend to your own Supabase project and did not copy the schema.
- Your deployed environment still has the old project URL in its environment variables, while you are looking at the new project in the dashboard.
Open the deployed app, look at any failed request in the Network tab, and read the host name in the request URL. Compare it with the project reference in your Supabase dashboard. If they differ, fix the environment variable in your host (Vercel, Netlify, Lovable) and redeploy, because Vite bakes VITE_ values in at build time. If they match, run the migration against that project:
supabase link --project-ref YOUR_PROJECT_REF
supabase db push
Or paste the SQL for the missing table into the SQL Editor. When you create a table by hand, remember the other two parts that every new table needs, which are enable row level security and the grants. The permission denied for table guide has the exact block to copy.
Case 3: the table lives in another schema
By default only the public schema is exposed through the Data API. If an AI tool put your table in app, private or any other schema, a request for invoices will not find it. Supabase's documentation for custom schemas gives the steps:
- Go to the API settings and add the schema to Exposed schemas.
- Grant the API roles access to it:
grant usage on schema app to anon, authenticated, service_role;
grant all on all tables in schema app to anon, authenticated, service_role;
Then tell the client which schema to use, either for one query or for the whole client:
const { data, error } = await supabase
.schema("app")
.from("invoices")
.select("*");
Stop and think before exposing a schema. Everything inside it becomes reachable with your public key, so every table in it needs row level security. If the schema was private on purpose, for example for internal tables, leave it private and reach it through a function or an Edge Function instead. If more than one schema is exposed, the first one in the list is the default for unqualified names, which is another way to get this error.
Case 4: the table is there but the cache is stale
Only when the table or column exists in the right project and the right schema, and the error persists, is the cache the problem. PostgREST keeps a copy of your database structure in memory and rebuilds it when it is told something changed. Supabase normally sends that notice by itself after schema changes. If the notice was missed, for example because the change happened while the service was reconnecting, ask for a rebuild by hand:
notify pgrst, 'reload schema';
Run it in the SQL Editor of the failing project, wait a second, and retry the request. You do not need to pause or restart the project. If the same error comes back right away, go back to Case 1, 2 or 3, because a reload only helps when the object really exists.
For PGRST204 the same logic applies to columns. The classic version is an app that sends { due_date: ... } in an insert while the migration that adds due_date was generated but never applied. Add the column, reload, and retry:
alter table public.invoices add column if not exists due_date date;
notify pgrst, 'reload schema';
Related errors that look similar
- PGRST202 is the same idea for a function: "Could not find the function public.name(args) in the schema cache". For
supabase.rpc()calls, the JSON keys you pass must match the parameter names in the function exactly. - PGRST200 means a relationship used in a join, such as
select("*, customers(*)"), was not found. Check that a foreign key actually exists between the two tables. - PGRST106 means the schema you asked for is not exposed, so go back to Case 3.
- 42501 permission denied means the table was found and the role has no grant. That is a different fix.
Prevention
Keep every schema change as a migration file in your repository, and apply it to each environment on purpose. Do not let the AI run ad hoc SQL in one project and then tell it to write code against a table you have not checked. After any schema change, regenerate your TypeScript types so the editor tells you about a column mismatch before your users do. Put the project URL in one place per environment and check it whenever you create a preview or move hosts. And finish every new table with row level security and grants in the same migration, so a table that works never ends up half set up.
FAQ
What is the difference between PGRST205 and PGRST204?
PGRST205 means the table in the URL was not found, with HTTP status 404. PGRST204 means a column named in the request, for example in an insert or update body, was not found on that table, with HTTP status 400. Both are reported as 'in the schema cache'.
Do I need to restart my Supabase project?
No. The SQL line notify pgrst, 'reload schema'; rebuilds the cache in place. If the table still is not found after that, it is not in that project or that schema, and a restart will not change it.
It says the table does not exist but I can see it in the dashboard. Why?
The usual reasons are a different project than the one the app calls, a table in a schema that is not exposed, or a name that differs in case or spelling. Check the Supabase URL in the deployed environment first.
Is PGRST205 the same as permission denied for table?
No. PGRST205 means the API does not know the table at all. Permission denied for table (code 42501) means it knows the table and the role has no grant. The fixes are different, so read the code before changing anything.
Why did this start right after Lovable or Cursor changed my database?
The tool changed the code and the SQL migration separately. If the migration was never applied to your project, the code now asks for a table or column that is not there. Apply the migration, then reload the cache.
Related guides
- Supabase "permission denied for table" on a new table: add the missing GRANT
- Lovable + Supabase RLS not working: why your data is empty (and how to fix it)
- Fix “new row violates row-level security policy” (Supabase error 42501)
- Lovable + Supabase Edge Function CORS error: why the browser says failed to fetch
- Supabase auth email not sending in a Lovable app: the SMTP setup that actually works