Fix guides · Lovable, Bolt, Cursor, Claude Code, Replit ·

Fix Supabase "Could not find the table … in the schema cache" (PGRST205)

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

Supabase's API (PostgREST) can't find the table your code asks for. Most often the table doesn't exist in this project yet (the AI wrote code for it but the migration never ran), the name or schema is different, or the API's schema cache hasn't picked up a new table. In the SQL editor the same problem shows as relation "public.profiles" does not exist (42P01).

Free · 3 a day · no signup

Common causes – and how to tell which one you have

1. The table was never created

How to tell: The AI wrote code (and maybe a migration file) for the table, but Table Editor doesn't show it. Common in Lovable, Bolt and Cursor projects after a failed or skipped migration.

Fix: Run the migration in the SQL Editor or with supabase db push. Make sure it also enables RLS and creates the policies.

2. The name doesn't match

How to tell: The table is called profile, user_profiles or Profiles, but the code uses profiles. Postgres names are case-sensitive when created with quotes.

Fix: Use the exact table name in supabase.from(), or rename the table. Regenerate the TypeScript types afterwards.

3. The app points at a different Supabase project or branch

How to tell: The table exists in the dashboard you're looking at, but NEXT_PUBLIC_SUPABASE_URL / VITE_SUPABASE_URL in your environment belongs to another project or a preview branch.

Fix: Fix the URL and anon key in your environment variables (also on Vercel/Netlify), or run the migration on the project the app really uses.

4. The schema cache is stale

How to tell: You just created the table with SQL and it's visible in Table Editor, but the API still says it can't find it.

Fix: Run NOTIFY pgrst, 'reload schema'; in the SQL Editor and try again.

5. The table is in another schema or not granted to the API

How to tell: The table lives in a schema like private or app, or you query users (Supabase users are in auth.users, which the API doesn't expose). On newer projects a table created with SQL also needs explicit grants for anon/authenticated.

Fix: Create a public.profiles table linked to auth.users instead of querying auth.users. For other schemas, expose the schema and use supabase.schema('name'). Grant only the privileges each role needs and keep RLS on.

How to fix it

  1. Open the Supabase dashboard of the project your app actually uses (compare the project URL in your .env with the dashboard URL).
  2. Go to Table Editor and check that the table exists in the public schema with the exact name from the error (lowercase, plural or singular).
  3. If it's missing, run the CREATE TABLE migration the AI wrote (SQL Editor or supabase db push), including RLS policies.
  4. If you created the table with SQL, grant the API roles access, e.g. grant select, insert, update, delete on table public.profiles to authenticated; and enable RLS with policies.
  5. If the table exists, reload the schema cache: run NOTIFY pgrst, 'reload schema'; in the SQL Editor.
  6. If the table is in another schema, call supabase.schema('name').from('table') and add the schema to Exposed schemas in the API settings.
  7. Reload the app and repeat the request.

Using Lovable, Bolt or v0?

In Lovable or Bolt, paste the error and say: "Check if the profiles table exists in the connected Supabase project. If not, create it with a migration that enables RLS and adds policies for the logged-in user. Don't turn off RLS."

Using Cursor, Claude Code or Windsurf?

Ask Cursor or Claude Code to compare every supabase.from() table name with the migrations folder, then write one migration for anything missing. If you use the Supabase CLI, have it run supabase db push and regenerate types.

The “fix” to avoid

Agents sometimes switch to the service_role key or disable RLS when they see database errors. Neither creates a missing table, and both expose your data. Create the table, fix the name, or reload the schema cache.

Copy-paste fix prompt for your AI coding tool

Paste this into Cursor, Claude Code, Lovable or Bolt:

Supabase returns "Could not find the table 'public.profiles' in the schema cache" (PGRST205). Find every supabase.from('...') call and list the table names. Compare them with the migrations in supabase/migrations and the types file. For a missing table, write one migration that creates it with the columns the code uses, enables RLS, adds policies so users can only access their own rows (auth.uid()), and grants access to the authenticated role. For a typo, fix the code to use the real table name. Don't use the service_role key in the browser and don't disable RLS. Tell me which SQL I need to run.
Your error looks a bit different? Paste your exact error and get a diagnosis tailored to your code — free.

Questions people ask

What does "Perhaps you meant the table …" mean?

Supabase found a table with a similar name. That's usually the real one: fix the name in your code.

Why does the SQL Editor say relation "public.profiles" does not exist?

Same problem, different layer. Postgres itself can't find the table (error 42P01), so the API can't either. Create the table or fix the name.

How do I query the users table?

You can't query auth.users through the API. Create a public.profiles table with id references auth.users(id) and fill it with a trigger or on sign-up.

Official documentation

Related errors

Get fixes like this every week