# Supabase "permission denied for table" (42501): how to fix it

Source: https://vibe-fixer.com/guides/supabase-permission-denied-for-table-42501
Last updated: 2026-11-17

**Short answer:** Supabase returns "permission denied for table" (code 42501) when the role your app uses through the API has no GRANT on that table. Since 30 October 2026 Supabase no longer grants API access to new tables in the public schema in existing projects, so add the GRANT, turn on row level security and add policies in the same step.

## Key takeaways

- `permission denied for table` (code 42501) means the role your app uses through the API has no GRANT on that table.
- Since 30 October 2026, new tables in the public schema are not reachable through the Data API until access is granted.
- Add the GRANT, turn on row level security and add policies in the same step.
- Do not run a bare `grant select ... to anon` on a table with row level security off, because anyone with your publishable key could read every row.
- If the error appears only on insert or update on a table that already had access, row level security is blocking the write, so you need a policy, not a grant.

To get this SQL filled in with your table name, use our free [Supabase 42501 GRANT SQL generator](https://vibe-fixer.com/tools/fix-42501): it turns on row level security, then adds the grants and Supabase's example policy.

Login, emails or payments broke in your live app? Our AI agent fixes it in your code, then tests your live app again.

Do not fix it with a bare `grant select ... to anon` on a table whose row level security is off: anyone with your publishable (anon) key could then read every row, and that key is in your app's front end.

**Fixed in your code, then tested live.** [Check my app free](https://vibe-fixer.com/?src=guide-supabase-permission-denied-f-t#triageForm)

## What does Supabase "permission denied for table" (42501) mean, and what fixes it?

It means Postgres refused the request because the role lacked a privilege: 42501 is the standard code `insufficient_privilege` ([PostgreSQL error codes](https://www.postgresql.org/docs/current/errcodes-appendix.html)). Which fix applies depends on what you see: a missing GRANT on a recently created table, row level security blocking a write, a schema you created yourself, the auth or vault schema, restricted columns, or missing access to a sequence.

- **A save, a list or sign-up fails with code 42501 "permission denied for table" on a table you created recently:** the table has no GRANT for the API roles. Fix: the steps below.
- **The same error only on insert or update, on a table that already had access:** row level security is blocking the write. Fix: a policy, not a grant ([Supabase: row level security](https://supabase.com/docs/guides/database/postgres/row-level-security)).
- **42501 on a table in a schema you created yourself:** the API has no permission on that schema. Fix: give the API access to the schema ([Supabase: 42501 errors](https://supabase.com/kb/troubleshooting/database-api-42501-errors)).
- **42501 when your app reads the auth or vault schema:** API roles cannot reach those schemas, by design ([Supabase: 42501 errors](https://supabase.com/kb/troubleshooting/database-api-42501-errors)).
- **42501 with `select *` on a table where some columns are restricted:** column-level privileges block the query. Fix: select only the columns the role may read.
- **Inserts may fail on a table with an auto-numbered id:** the roles may be missing access to its sequence. Fix: grant usage on the sequence too.

- **42501 "permission denied for table http_request_queue":** the error comes from the pg_net extension's request queue, not from your table. Follow [Supabase: 42501 on http_request_queue](https://supabase.com/docs/guides/troubleshooting/42501--permission-denied-for-table-httprequestqueue-KnozmQ).

## Why did my new table start returning "permission denied for table" (42501)?

Supabase applied a change to all existing projects on 30 October 2026, so new tables in the public schema are not reachable through the Data API until access is granted.

Supabase announced on 28 April 2026 that new tables in the public schema are not reachable through the Data API until access is granted. It became the default for new projects from 30 May 2026, rolled out over a few weeks, and was applied to all existing projects on 30 October 2026. Tables you already have keep their current grants and stay reachable; the change hits tables created after it ([Supabase changelog](https://supabase.com/changelog/45329-breaking-change-tables-not-exposed-to-data-and-graphql-api-automatically)).

Before the change, every new table in public was granted to the anon, authenticated and service_role roles automatically. That is why an older table works and the one your AI tool just created does not.

The error your app gets back has code `42501` and the message `permission denied for table your_table`, with a hint that names the missing role and privilege and shows the GRANT statement to run, for example one for anon.

## Is the GRANT in the 42501 hint enough to fix it?

No: the hint names the missing GRANT but does not check row level security, so the grants, enabling row level security and the policies belong in the same migration.

Grants decide whether a role can reach a table; row level security decides which rows. Supabase's advice is to treat three things as one unit, in the same migration: the grants, enabling row level security, and the policies ([Supabase changelog](https://supabase.com/changelog/45329-breaking-change-tables-not-exposed-to-data-and-graphql-api-automatically)).

## How do I fix "permission denied for table" safely, role by role?

Turn on row level security, grant the roles you need on the table, and add policies so each signed-in user reads and changes only their own rows.

Run these in the SQL Editor of your project, or put them in the migration that creates the table. Replace `your_table` and `user_id` with your table and its owner column.

1. Turn on row level security first: `alter table public.your_table enable row level security;`
2. Signed-in users (the authenticated role): `grant select, insert, update, delete on public.your_table to authenticated;`
3. Your server code (the service_role role): `grant select, insert, update, delete on public.your_table to service_role;`
4. Signed-out visitors (the anon role), only if they really need to read this table: `grant select on public.your_table to anon;` and add a select policy `to anon`, or signed-out visitors still get an empty list. Most private tables should not get this line.
5. Let each signed-in user read only their own rows: `create policy "own rows: read" on public.your_table for select to authenticated using ((select auth.uid()) = user_id);`
6. Let them add only their own rows: `create policy "own rows: insert" on public.your_table for insert to authenticated with check ((select auth.uid()) = user_id);`
7. Let them change only their own rows: `create policy "own rows: update" on public.your_table for update to authenticated using ((select auth.uid()) = user_id) with check ((select auth.uid()) = user_id);`
8. Let them delete only their own rows: `create policy "own rows: delete" on public.your_table for delete to authenticated using ((select auth.uid()) = user_id);`
9. If the table has an auto-numbered id: `grant usage, select on all sequences in schema public to authenticated, service_role;`

If you use migrations, keep these in the same migration that creates the table, so the next new table does not break the same way. More on roles and grants: [Supabase: securing your API](https://supabase.com/docs/guides/api/securing-your-api).

## How do I check which roles can reach the table?

Query the table's grants and which public tables have row level security off, or look at the Data API exposure badge in the Table Editor.

- Which roles have which rights on the table: `select grantee, privilege_type from information_schema.role_table_grants where table_schema = 'public' and table_name = 'your_table';`
- Which public tables have row level security off: `select relname as table_name, relrowsecurity as rls_on from pg_class where relnamespace = 'public'::regnamespace and relkind = 'r' order by 2, 1;` Any row with `rls_on = false` is a table to fix before you add grants to it.
- In the dashboard, the Data API exposure badge in the Table Editor shows which tables are exposed. Before 30 October the Security Advisor also flagged affected tables.

## How do I check that the data is hidden while signed out?

Call the table with only the publishable (anon) key and no sign-in token, on a table that has rows in it. Use the same key your app's front end uses. For example, call `https://YOUR-PROJECT.supabase.co/rest/v1/your_table?select=*&limit=5` with the header `apikey: YOUR_PUBLISHABLE_KEY`.

- An empty list on a table that has rows: signed-out visitors see nothing. This is what you want for private data.
- Rows come back: anyone with the public key can read them. If that is not intended, check `rls_on` and the table's policies before anything else.
- 42501 permission denied: signed-out visitors have no grant on this table. Fine if they should not read it.

Then sign in as one test user in your app and confirm you see your own rows and not another user's.

## How do I check it's fixed?

Repeat the action that failed, on your live app, as a person who has never used it.

1. Open your live app in a private (incognito) window.
2. Sign up with a brand-new email address, or sign in as a test user who is not you.
3. Do the thing that failed before: save, add or list the data on the new table.
4. Check that it saves and that the data is still there after a page refresh.
5. Sign up a second new test user and check they cannot see the first user's rows.

## Why do my older tables work while a new table fails with 42501?

Tables you made earlier keep their access, while a table added after the change fails until it gets its grant. So the pages you use most keep working, and a table your AI tool just created does not.

## New tables in public need explicit grants before the Data API can reach them

Supabase's changelog describes a change that applies to existing projects from 30 October 2026: a new table in the `public` schema is not reachable through the Data API until it has an explicit grant. That is why a table your AI agent or builder just created can return `permission denied for table` (42501) while older tables still work.

1. Add the grants in the same migration that creates the table, for the roles your app uses: `grant select, insert, update, delete on public.your_table to authenticated;`
2. Turn on row level security in the same migration: `alter table public.your_table enable row level security;`
3. Add a policy so each signed-in user reads and changes only their own rows.
4. Grant `select` to `anon` only if the table is meant to be public, and only after the policies are in place.
5. Run the SQL in the SQL Editor, or as part of your migration, then load the page again while signed in.
6. To fill in your table name and get the SQL, use the [42501 GRANT SQL generator](https://vibe-fixer.com/tools/fix-42501).

## Frequently asked questions

### Why did 42501 start after 30 October 2026?

Supabase applied a change to all existing projects on 30 October 2026: new tables in the public schema are no longer reachable through the Data API until you grant access. Tables you already had keep their grants.

### Will my old tables break?

No. Existing tables keep their current grants and stay reachable. Only tables created after the change need explicit grants.

### Should I just run grant select to anon?

Only if signed-out visitors really need to read that table, and only with row level security turned on and a policy in place. With row level security off, the anon grant lets anyone with your publishable key read every row.

### Is 42501 a row level security error?

It can be either. A missing grant gives 42501 before any policy runs. Row level security also returns 42501 when it blocks an insert or update. Check the grants first, then the policies.

### Does this affect tables an AI builder creates for me?

Yes, the same way. A table created by an AI builder, a script or a migration after the change needs its grants, row level security and policies like any other new table.

### Where can I see which tables are exposed?

The Data API exposure badge in the Table Editor of your Supabase dashboard shows which tables are exposed. Before 30 October the Security Advisor also flagged affected tables.

### Can VibeFix fix it for me?

Yes, for any app whose code is on GitHub, whichever tool built it (Lovable, Bolt, Base44, Replit, v0, Cursor). 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 $29 and tests your live app again. See [pricing](https://vibe-fixer.com/pricing).

## Related guides

- [Who can fix my AI-built app?](https://vibe-fixer.com/guides/vibe-coding-expert)
- [App fix price](https://vibe-fixer.com/pricing)
- [Database error querying schema (Supabase): fix](https://vibe-fixer.com/guides/supabase-database-error-querying-schema)
- [Duplicate key value violates unique constraint](https://vibe-fixer.com/guides/supabase-duplicate-key-value-violates-unique-constraint)
- [42P01: relation does not exist](https://vibe-fixer.com/guides/supabase-42p01-relation-does-not-exist)
- [PGRST106: The schema must be one of the following](https://vibe-fixer.com/guides/supabase-pgrst106)
- [Could not find the table in the schema cache](https://vibe-fixer.com/guides/supabase-could-not-find-table-in-schema-cache)
- [PGRST002: Could not query the database for the schema cache](https://vibe-fixer.com/guides/supabase-pgrst002-schema-cache-retrying)

## Sources (official documentation)

- [Supabase changelog: tables not exposed to the Data API automatically (dates, grants, RLS, policies)](https://supabase.com/changelog/45329-breaking-change-tables-not-exposed-to-data-and-graphql-api-automatically)
- [Supabase troubleshooting: Database API 42501 errors](https://supabase.com/kb/troubleshooting/database-api-42501-errors)
- [Supabase: row level security](https://supabase.com/docs/guides/database/postgres/row-level-security)
- [Supabase: securing your API](https://supabase.com/docs/guides/api/securing-your-api)
- [PostgreSQL: error codes (42501 insufficient_privilege)](https://www.postgresql.org/docs/current/errcodes-appendix.html)

## Still broken?

If the error is gone but your live app still breaks for new users, start with a free check: our AI agent tries your live app like a new user and shows you what breaks. Then, on request, it reviews your code independently, because VibeFix is independent of every app builder. It fixes it in your code and re-checks your live app. The free check signs up once as "VibeFix Test" with its own inbox, needs no account, never changes your app and never emails your users. Today the fix is for apps built with Lovable, or any app whose code is on GitHub.

**Fixed in your code, then tested live.** [Check my app free](https://vibe-fixer.com/?src=guide-supabase-permission-denied-f-m#triageForm)

Related: [Supabase RLS policy generator](https://vibe-fixer.com/tools/rls-policy-generator) · [Fix 42501 tool](https://vibe-fixer.com/tools/fix-42501) · [Data won't save: "new row violates row-level security policy"](https://vibe-fixer.com/guides/data-wont-save-row-level-security) · [Edits or upserts blocked by row-level security](https://vibe-fixer.com/guides/data-wont-save-row-level-security) · [Users can see other users' data in my Lovable app](https://vibe-fixer.com/guides/users-can-see-other-users-data) · ["Database error saving new user"](https://vibe-fixer.com/guides/supabase-database-error-saving-new-user) · [ShipFix alternatives: services that fix a vibe-coded app](https://vibe-fixer.com/compare/shipfix-alternatives-fix-vibe-coded-app)

VibeFix is independent. Lovable, Bolt, Replit, Base44, v0, Supabase, Firebase, Stripe and Vercel are trademarks of their owners.

Want it fixed for you? For any app whose code is on GitHub, whichever tool built it, VibeFix's AI agent can find the cause of this error, fix it in your code and re-check your live app. Start with a free check: https://vibe-fixer.com
