Vigia › Help › Supabase error 42501

Supabase error 42501 “permission denied”? The safe fix

Published 30 October 2026 · About 4 minutes · For apps built with Lovable, Bolt, Cursor or by hand on Supabase

Short answer: Supabase has stopped granting access to new tables in the public schema automatically. From 30 October 2026 this applies to all existing projects, so a table you create now isn’t reachable through the Data API until you grant it. Don’t open it up to everyone. In one migration, grant each role only what it needs, enable Row Level Security and add one policy per operation.

Vigia publishes this page and sells an automated check for other problems (see the end). It is not a security audit or a guarantee.

On this page: The problem · Why it happens · The safe fix · How to check it worked · Prompt for Lovable, Bolt and Cursor · FAQ · What Vigia checks · Sources

The problem

A request from your app (through supabase-js or /rest/v1/) to a table you just created fails with:

{
  "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 hint names the role and the privilege that are missing.

Why it happens

Until now, Supabase gave anon, authenticated and service_role select, insert, update and delete on every new table in public, so each table was reachable through the Data API as soon as it existed. Supabase changed that default. In its changelog: “On October 30, 2026 the setting will be applied it [sic] to all existing projects.” After that, “new tables you create in public schema require an explicit opt-in (via a Postgres grant) before the Data API can see them.”

The safe fix

Supabase: “Treat these three steps as a unit.” Put them in the same migration, for each new table your app reads or writes:

  1. Grant only what each role needs. For example, read-only for logged-out visitors and full access for signed-in users:
    grant select on public.your_table to anon;
    grant select, insert, update, delete on public.your_table to authenticated;
    If logged-out visitors should not see this table at all, don’t grant anything to anon.
  2. Enable RLS: alter table public.your_table enable row level security;
  3. Add one policy per operation. For example, so each user only reads their own rows:
    create policy "users can read their own rows"
      on public.your_table
      for select
      to authenticated
      using (auth.uid() = user_id);

Don’t fix the error by granting everything to anon, and don’t turn RLS off. Supabase warns: “Tables and views exposed through the Data API without RLS can be accessed by any role with matching grants.” Your publishable key is public by design, so that would make the table reachable by anyone who opens your site.

How to check it worked

  1. Repeat the request that failed. The 42501 error should be gone.
  2. Expect empty results until the policy exists. With RLS on and no policy, Postgres uses “a default-deny policy … meaning that no rows are visible or can be modified”.
  3. Test as a stranger. Open your app in a private window, logged out, and check that private data never loads.
  4. Run the Security Advisor in the Supabase dashboard. Supabase says it flags tables affected by this change and shows SQL to fix them; the Data API exposure badge in the Table Editor also lists tables worth reviewing.

Prompt for Lovable, Bolt and Cursor

For every new table in the public schema, write one migration that grants only the privileges anon and authenticated need (nothing to anon if logged-out users shouldn’t see it), enables Row Level Security, and adds one policy per operation so each user only reaches their own rows. Never grant all privileges to anon and never disable RLS. Show me the SQL before running it.

FAQ

Why do only my new tables fail?

Supabase’s change only affects tables created after it reaches your project. Existing tables keep their current grants and stay reachable.

Can I just grant everything to anon to make the error go away?

Don’t. Grant each role only what your app needs, and enable RLS with policies in the same migration. Supabase warns that tables exposed through the Data API without RLS can be accessed by any role with matching grants.

I added the grant and now I get no rows. Is that a bug?

No. With RLS enabled and no policy for that operation, Postgres uses default deny: no rows are visible or can be changed. Add a policy for each operation your app needs.

Does this affect apps that connect to Postgres directly?

No. Supabase says the change applies to the Data API (REST and GraphQL, used by supabase-js). Direct connections with psql, an ORM or a connection string are not affected.

Does it affect the auth, storage or custom schemas?

No. Supabase says the change only touches default privileges in the public schema.

What Vigia checks

Vigia doesn’t read your database, grants or policies, so it can’t tell you whether a table is reachable or protected. It is a read-only check of what your live site already exposes to any visitor, such as a Supabase secret or service_role key in your JavaScript (see Supabase service_role key exposed?) or a public .env or .git. A clean report is not a security guarantee. Run the free check

Sources

Supabase, PostgreSQL, Lovable, Cursor and Bolt are trademarks of their respective owners. Vigia is not affiliated with or endorsed by them.

Last reviewed 30 October 2026 against the official docs listed above.