Skip to content
VibecodeZero

Supabase "permission denied for table" (42501) on a new table: how to fix it

Updated

On this page (4)
  1. Symptom
  2. Cause
  3. Prompt to paste
  4. How not to burn credits

Symptom

You created a new table in Supabase, or your AI tool did, and the app can't read or save anything in it. The request fails with {"code":"42501","message":"permission denied for table your_table"}, or the table doesn't seem to exist in the API, even though you can see it in the dashboard. Older tables still work.

Cause

This page is for apps that use their own Supabase project and talk to it through the Data API: the supabase-js library, another Supabase client library, or requests to /rest/v1/ or /graphql/v1. If you’re not sure whether that’s your app, the prompt on this page asks the AI to check first.

The facts here come from Supabase’s changelog post Breaking change: tables not exposed to Data and GraphQL API automatically, its troubleshooting guide Database API 42501 errors, and its docs on securing your API, API keys and creating API routes, all checked October 30, 2026. We haven’t confirmed whether Lovable Cloud or Bolt’s built-in database are affected, and Supabase’s changelog doesn’t mention them. None of the links on this page are affiliate links.

What changed on October 30, 2026

Until now, when you created a table in the public schema, Supabase automatically gave three roles permission to read, add, change and delete in it: anon (visitors who aren’t signed in), authenticated (signed-in users) and service_role (server code). So the table was reachable through the Data API the moment it existed.

Supabase changed that in three steps, according to its changelog:

  • April 28, 2026: you could choose the new behavior when creating a project.
  • May 30, 2026: it became the default for new projects, rolled out gradually over a few weeks.
  • October 30, 2026: it was applied to all existing projects.

Now a new table in public needs an explicit opt-in, a Postgres GRANT, before the Data API can see it. Existing tables aren’t affected: Supabase says they keep their current grants and stay reachable. Supabase emailed the owners and admins of active projects about it, the last time on October 23.

Who is affected, and who isn’t

Affected, according to Supabase:

  • Apps that use the Data API: supabase-js, other client libraries, or direct requests to /rest/v1/ or /graphql/v1.
  • Migrations or setup scripts that create public tables without a GRANT.
  • AI coding tools, CLI scripts or Management API calls that create a table and expect to use it right away. If you ask an AI tool to “add a table for orders”, the table may be created and still be unreachable from your app.

Not affected:

  • Apps that only use a direct Postgres connection: psql, an ORM, or an app server with a connection string.
  • Tables in Supabase’s own storage, auth and realtime schemas.
  • Tables you already had before the change.

The exact error

When the app tries to use a new table without a grant, Supabase’s changelog shows this response:

{"code":"42501","message":"permission denied for table your_table","hint":"Grant the required privileges to the current role with: GRANT SELECT ON public.your_table TO anon;"}

The table name appears where it says your_table, and the role in the hint tells you who was refused. anon means the request came from someone who wasn’t signed in, and authenticated means a signed-in user.

Supabase says a missing grant makes Postgres reject the query before RLS rules are even checked. That’s why this error can appear even when your RLS policies are correct.

Check the table’s grants

You can see who has access to a table in the SQL editor of your Supabase dashboard. Supabase’s troubleshooting guide gives this query. Replace your_table with the table’s name and keep the quotes:

select grantee, privilege_type
from information_schema.role_table_grants
where table_name = 'your_table';

Each row is one permission for one role. If anon or authenticated aren’t in the list, your app can’t reach the table through the Data API.

Supabase also says its Security Advisor flags the affected tables and shows the SQL to fix them, and the Table Editor shows a Data API exposure badge, so you can find every table to review.

The fix: grants, RLS and policies in the same migration

Supabase’s changelog suggests these grants for a new table, in the same migration that creates it:

grant select on public.your_table to anon;
grant select, insert, update, delete on public.your_table to authenticated;
grant select, insert, update, delete on public.your_table to service_role;

Then, still in the same migration, it turns on RLS and adds policies:

alter table public.your_table enable row level security;

Followed by one create policy statement for each rule, like “people can only see their own rows”. You don’t need to write these yourself. The prompt on this page asks the AI to write the whole migration and explain it before it runs.

Two things to decide with the AI before you run it:

  • Does anyone who isn’t signed in need this table? The first line gives anon read access. If only signed-in users should see the table, ask whether that grant is needed at all. Grant only what your app uses.
  • Are the policies right? The grants open the door to the table. The policies decide which rows each person reaches. Test with two accounts afterwards: Could my app be exposing personal data? shows how.

Grants don’t replace RLS

Supabase says “RLS behavior remains unchanged.” A grant controls whether a role can access the table. RLS controls which rows it can see. You need both.

Supabase’s docs are direct about the risk: tables exposed through the Data API without RLS “can be accessed by any role with matching grants”. And Supabase’s publishable key, the one your app’s browser code uses, is designed to be public: Supabase says it only reaches what RLS allows. So a table with grants for anon and no RLS is open to anyone who opens your app. Never fix this error by granting everything and skipping RLS, and never turn RLS off to make an error go away.

Supabase’s docs also say tables created in the dashboard have RLS turned on by default, while tables created in the SQL editor or other tools need it turned on explicitly. A table your AI tool created is in the second group, so check it.

If your app is on Lovable, the Lovable security checklist for non-coders shows how to check your database rules without coding.

Stop it from happening with the next table

Supabase recommends bundling the GRANT statements with enable row level security and the policies in every migration that creates a table. It also suggests its Supabase agent skill, which includes the grants step, or updating your AI tool’s instructions. In practice: add the last line of the prompt on this page to your project’s rules or custom instructions, so the AI does all three every time it adds a table.

Supabase’s changelog also shows how to bring back the old automatic grants for future tables, and its docs describe an Automatically expose new tables setting in the Data API settings (Integrations > Data API in the dashboard). We don’t recommend going back to it: granting per table, together with RLS, is what makes you check each new table’s rules.

For the other database error codes, like 23505 or PGRST116, see How to fix database errors in a vibe-coded app. If you’re thinking of moving a Lovable app to your own Supabase project, How to move from Lovable Cloud to your own Supabase project covers it, and new tables you add there after the move need these grants too.

Prompt to paste

Copy the text below, replace what’s in brackets and send it in the chat of the tool you’re using.

Paste into the AI
My app uses its own Supabase project through supabase-js (the Data API).
Since Supabase's change on October 30, 2026, new tables in the public schema are no longer exposed to the Data API automatically. They need an explicit GRANT.
I get this error: [paste the exact error, including the code and the hint]
The table is: [table name, if you know it]

Don't change anything yet. First:
1. List every table in the public schema that the app reads or writes through supabase-js, and tell me which ones have no grants for anon, authenticated or service_role.
2. For each one, tell me who needs it: visitors who aren't signed in (anon), signed-in users (authenticated), or only server code (service_role).

Then propose ONE migration that, for each of those tables, in the same file:
- grants only the privileges the app really needs, to only the roles that need them. No grant to anon unless visitors who aren't signed in must use the table;
- enables Row Level Security;
- creates policies so each person only reaches the rows they should, for example only their own rows.
Don't grant anything on a table without enabling RLS and adding policies in the same migration. Never put the service_role or secret key in browser code.

From now on, every migration that creates a table in the public schema must include its grants, enable RLS and its policies in the same file.
Explain the migration in plain English and wait for my confirmation before running it.

How not to burn credits

  • Paste the exact error, with the code 42501 and the hint. It names the table and the role, so the AI doesn't have to guess.
  • Ask for one migration that covers every new table at once, instead of fixing tables one by one as each error appears.
  • Don't ask the AI to "rebuild the database" or recreate the table. The table is fine. It's missing a permission.
  • Add the rule from the last line of the prompt to your project's instructions, so the next table the AI creates already comes with grants, RLS and policies.

How Lovable counts credits, and what the free plan includes: Lovable credits explained.

Questions people ask

What does "permission denied for table" mean in Supabase?

It means the database role your app uses, like anon for visitors who aren't signed in or authenticated for signed-in users, has no permission on that table. The error code is 42501. Since October 30, 2026, Supabase doesn't give new tables in the public schema those permissions automatically, so a table created after that date returns this error through the Data API until you add a GRANT. Supabase's hint in the error even shows the command, for example GRANT SELECT ON public.your_table TO anon.

Why doesn't my new Supabase table show up in the API?

Because of the same change. Supabase's changelog says new tables in the public schema now need an explicit opt-in, with a Postgres GRANT, before the Data API and GraphQL API can reach them. You can see the table in the dashboard, but supabase-js, /rest/v1/ and /graphql/v1 can't use it until the roles your app uses get a GRANT.

What is Supabase error 42501?

42501 means insufficient privileges. Supabase's troubleshooting guide lists several causes: a missing table privilege ("permission denied for table"), a restricted column, a schema the API can't reach, or a row that an RLS policy doesn't allow you to add or change. If the table is new and the message says "permission denied for table", start with the grants. For the other causes, see our page on database errors in a vibe-coded app.

My old tables still work. Why only the new one?

Supabase says existing tables keep their current grants and stay reachable. The change only affects tables created after it reached your project. It was applied to all existing projects on October 30, 2026, and it was already the default for new projects created from May 30, 2026.

Is this happening because of Lovable Cloud or Bolt's database?

We haven't confirmed whether this change affects Lovable Cloud or Bolt's built-in database, so we can't say. Supabase's changelog doesn't mention them. This page is about apps that use their own Supabase project. If your app is on a built-in backend and you see this error, copy it and ask your tool's support or the AI in your project what it means there.

Can I just grant everything to fix it?

No. Supabase's docs say tables exposed through the Data API without RLS can be accessed by any role with matching grants. A grant decides whether a role can use the table at all, and RLS decides which rows it sees. So add the grants and, in the same migration, turn on RLS and write policies. Only grant what your app uses, to the roles that need it.

How do I find which tables are affected?

Supabase says its Security Advisor flags the affected tables and shows the SQL to fix them, and the Table Editor shows a Data API exposure badge. You can also check one table's grants in the SQL editor with the query on this page. If no row lists anon or authenticated, the app can't reach that table through the Data API.

My app connects with a connection string, not supabase-js. Am I affected?

Supabase says apps that only use a direct Postgres connection, like psql, an ORM or an app server with a connection string, aren't affected. Tables in Supabase's storage, auth and realtime schemas aren't affected either.

New guides by email. An email when we publish a new guide, error fix or chapter, in plain English. Subscribe