Error 42501 "permission denied for table" on Supabase and Lovable: the cause and the right fix

By Nathan Guigui, Founder of GUIGUI Tech · Facts checked against the official sources listed at the end of the article

The error 42501 permission denied for table means your app has not been given the right to access a Supabase table. Since 2026, a new table is no longer open to the API by default: it needs privileges, given with a GRANT statement. The right fix is two moves, in this order: enable RLS and write its policies, then grant each role the minimum it needs. The wrong fix is the one AI tools often suggest: GRANT ALL to the anon role.

The information below was checked against Supabase's changelog and documentation, as of November 25, 2026.

What does the error look like?

According to Supabase's changelog, the API returns this message when a grant is missing:

{
  "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;"
}

In your app, you will not always see this text. According to Supabase's troubleshooting guide, this error is often reported as a 401 or 403 error. The typical symptom: a recently added feature shows nothing or refuses to save, while the rest of the app works.

Why is this error appearing now?

It appears because Supabase changed a default setting. Before, any table created in the public schema automatically received read and write privileges for the anon, authenticated and service_role roles. That is no longer the case.

DateWhat Supabase announces
April 28, 2026The new setting becomes available when creating a project
May 30, 2026It gradually becomes the default for new projects
October 30, 2026It is applied to all existing projects

Three useful details:

  • Only new tables are concerned. According to Supabase, existing tables keep their grants and stay reachable.
  • It does not matter who created the table. Supabase states that the grant is needed however the table was created: SQL editor, migration or AI tool.
  • The schedule is the announced one. The changelog does not confirm that the October 30 step is complete on every project. If you see error 42501 on a recent table, this is very likely the cause.

The safe fix, in 3 steps

Replace your_table with the name of your table. The statements are run in the Supabase SQL editor.

1. Enable RLS and write the policy first. As long as no grant is given, the table is closed: this is the right moment to protect it. The example assumes a user_id column holding the ID of the row's owner.

alter table public.your_table enable row level security;

create policy "Users read their own rows"
on public.your_table for select
to authenticated
using ((select auth.uid()) = user_id);

2. Grant the minimum. For a private table, only signed-in users need access:

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

Add the anon role only if signed-out visitors really need to read the table (a public catalogue, for instance), and read-only:

grant select on public.your_table to anon;

If server code (an Edge Function, for instance) uses the secret key, the service_role role needs its own GRANT too: the change applies to it as well.

3. Check the result. This query, adapted from Supabase's guide, lists who has which privileges on the table:

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

Key point

The error message itself suggests GRANT SELECT ... TO anon. Do not copy it without thinking: if the table holds user data, the grant belongs to the authenticated role, not to anon.

The trap: GRANT ALL to the anon role

Faced with this error, an AI tool tries to make it go away, and the bluntest statement does the job:

-- Avoid
grant all on public.your_table to anon;

The error disappears, the app works, and the problem becomes invisible. Yet according to Supabase's documentation, a table in an exposed schema without RLS is readable and writable by any role with a grant on it. The anon role is the one any signed-out visitor gets, and the key that uses it is visible in your app.

Before accepting a change suggested by the AI, ask it these three questions:

  1. "Is RLS enabled on this table?"
  2. "Explain the access policy in one plain sentence."
  3. "Why does the anon role need this privilege?"

If the answer to the third question is not clear, the privilege should not go to anon.

What about Lovable?

The change comes from Supabase, not from Lovable: it concerns any app whose database is a Supabase project, whichever tool wrote the code.

  • Your app is connected to your own Supabase project: apply the 3 steps above in the SQL editor. According to Supabase, the Security Advisor and the Data API exposure badge in the Table Editor list the tables worth reviewing.
  • You do not have access to the SQL editor: ask for the fix in Chat mode, and set the rules. For example: "Fix error 42501 on table X. First enable RLS with a policy that limits each user to their own rows. Then grant privileges to the authenticated role only. Do not use GRANT ALL, and do not grant anything to the anon role without asking me." Then read the change before accepting it.

Supabase also lets you go back to the old behaviour, where every new table is opened automatically (the "Automatically expose new tables" setting in the Data API settings). We advise against it: the new setting protects you precisely against the forgotten table.

If it is not a missing grant

According to Supabase's troubleshooting guide, error 42501 has other possible causes:

CauseWhat it means
Forbidden schema (auth, vault)These schemas are intentionally closed to the API
Custom schemaThe API has not been allowed to query this schema
Column-level privilegesThe role only has access to some columns, and the query asks for others
RLS policy on a writeA policy blocks inserting or updating a row

To go further on RLS and Supabase keys, see Is your Lovable app exposing your data?

Get help

This guide fixes an error on one table. It does not tell you whether the policies on your other tables are right, or whether a GRANT ALL already slipped into a past change.

If your Lovable app has real users, the security audit for your Lovable app costs €1,200 excl. VAT, in 3 business days. We check the RLS policies on every table, secret keys visible in the browser, protections that only exist on screen, user sign-in, uploaded files and third-party service keys, without changing anything. You get a plain-language written report covering what is serious, what is less so, and what to do. A new check after your own fixes costs €350 excl. VAT.

Frequently asked questions

What does error 42501 "permission denied for table" mean on Supabase?
It means the role your app uses (anon, authenticated or service_role) has not been given a privilege on the table. According to Supabase, since May 30, 2026 on new projects, and per its schedule since October 30, 2026 on existing projects, a new table in the public schema no longer receives these privileges automatically. They have to be given with a GRANT statement.
Why does my Lovable app show this error only on a new feature?
Because the change only affects tables created after it was applied. According to Supabase, existing tables keep their grants and stay reachable. A table added recently, by you or by an AI tool, arrives with no privileges for the API: only the part of the app that uses it fails.
The AI suggests GRANT ALL to anon: is that dangerous?
It can be. According to Supabase's documentation, a table in an exposed schema without RLS is readable and writable by any role with a grant on it. Giving every privilege to the anon role on a table without RLS, or with a policy that is too broad, opens that table to any signed-out visitor. Supabase recommends granting the minimum privileges each role needs.
What is the difference between a GRANT and RLS?
The GRANT decides whether a role can access the table. RLS decides which rows that role can read or change. According to Supabase, both should be used on every exposed table. A missing grant raises error 42501 before any RLS policy is even evaluated.
Will my existing tables stop working?
No, according to Supabase: existing tables keep their current grants and stay reachable. The change concerns the default privileges of future tables in the public schema.
Does error 42501 have other causes?
Yes. According to Supabase's troubleshooting guide, it can also come from a query on a forbidden schema (auth, vault), a custom schema the API is not allowed to query, column-level privileges, or an RLS policy blocking a write. Supabase notes that this error is often reported by clients as a 401 or 403 error.

Need help with this?

Security Audit for your Lovable App

€1,200 excl. VAT3 business days

Your Lovable or Bolt app has real users? We check that no stranger can see their data (Supabase, secret keys) and explain what to fix, in plain words.

Learn more →

More articles

Android developer verification in 2027: is your app registered?

Google is expanding Android developer verification worldwide starting January 2027. Who is affected, the known timeline and how to check that your app is registered.

Read more

Apple tightens App Store rules in 2026: what it means for an app built with Lovable or AI

June and October 2026: Apple tightens its rules against low-quality apps (4.3), hidden features (2.5.19) and misleading visuals (2.3.14). What it means for an app built with Lovable or AI.

Read more

Tell us about your project

Our office

  • France
    1 RUE DE STOCKHOLM
    75008, PARIS