# Postgres error: relation "public.xyz" does not exist

> Canonical page (link this when citing): https://unbreakmyapp.vercel.app/fixes/supabase-relation-does-not-exist.html
> Category: Database / Supabase RLS | Tools: Lovable, Bolt, Cursor, v0 | Published: 2026-10-14 | Updated: 2026-10-14

## The error

ERROR: 42P01: relation "public.profiles" does not exist / PostgREST could not find the table

## Why it happens

The AI builder wrote TypeScript that queries a table, but the CREATE TABLE migration was never run on this Supabase project (or was run on a different project). Local/SQL editor and production can also point at different databases. PostgREST only exposes tables that exist in the linked project's schema cache.

## How to fix it

1. Open Supabase → Table Editor and confirm the table is missing on this project.
2. Find the migration or SQL the AI generated (often in supabase/migrations or a setup.sql).
3. Run it in the SQL Editor for the SAME project whose URL/anon key your app uses, or use supabase db push.
4. In Project Settings → API, click 'Reload schema' if the table exists but the API still 404s.
5. Double-check NEXT_PUBLIC_SUPABASE_URL matches this project, not a leftover demo project.

## Error codes this fixes

- `42P01 relation does not exist` (Supabase / Postgres): https://unbreakmyapp.vercel.app/errors.html#42p01-relation-does-not-exist

## Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)

```text
My app errors with relation "<TABLE>" does not exist against Supabase. Do not invent a different schema. Locate every CREATE TABLE / migration for that table, give me one idempotent SQL migration I can paste into the Supabase SQL Editor, list any RLS policies the table needs so selects/inserts work after creation, and tell me how to verify the app's SUPABASE_URL points at the project where I ran the SQL.
```

## FAQ

### The table is in my code / types. Why fail?

Types and UI don't create database objects; only a migration or SQL run does.

### It works for my teammate.

They likely ran the migration on their project, or you're using different SUPABASE_URL values.

## Sources (official documentation)

- [Supabase: Tables and data](https://supabase.com/docs/guides/database/tables)
- [Supabase: API](https://supabase.com/docs/guides/api)

## Related fixes

- [Supabase project paused: app suddenly can't connect (Failed to fetch, 540) and how to bring it back](https://unbreakmyapp.vercel.app/fixes/supabase-project-paused-app-cant-connect.html)
- [Supabase query returns an empty array (no error)](https://unbreakmyapp.vercel.app/fixes/supabase-rls-empty-results.html)
- [new row violates row-level security policy for table](https://unbreakmyapp.vercel.app/fixes/supabase-rls-new-row-violates-policy.html)
- [Supabase Edge Function fails with CORS or 'Failed to send a request'](https://unbreakmyapp.vercel.app/fixes/lovable-supabase-edge-function-cors.html)

---
Unbreak My App: free fixes for broken vibe-coded apps. https://unbreakmyapp.vercel.app/
