Guides / permission denied for table
Supabase "permission denied for table" (42501): check the GRANT before the policy
Your app calls the Data API and gets permission denied for table your_table with code 42501. That error means the role making the request (usually anon or authenticated) lacks a privilege this query needs. It may already hold other privileges on the table, so check the operation and the columns first. A missing grant raises 42501 before any RLS policy runs, so rewriting policies will not clear it. The fix is a narrow GRANT for the operation you actually need, alongside the RLS you should already have.
The short answer
Postgres code 42501 is insufficient_privilege. In Supabase's words, a Postgres 42501 error implies the request lacked adequate privileges, and clients often report it as a 401 or 403. For the "permission denied for table" wording, Supabase says the querying role may not have the required privilege for the operation. That is the operation and columns your query used, not necessarily every privilege on the table.
Supabase describes the Data API as two layers. Grants decide whether a role can run an operation on a table at all. RLS policies decide which rows that operation applies to. A missing grant raises 42501 before any policy runs. So when a request fails that your policy should allow, check the grants before you touch the policy.
A new table starts out locked. In Postgres, for most kinds of objects the initial state is that only the owner (or a superuser) can do anything with the object, and other roles need privileges granted. Supabase has granted access to new public tables automatically, which hides that step, and it is changing that default. If your app reaches a newly created table through the Data API, the missing grant can now show up as this error.
Why it can appear on new tables
Supabase's changelog announced that new tables in the public schema are no longer exposed to the Data API automatically. The dates it gave: from May 30, 2026 the setting starts to become the default for new projects, as a gradual rollout over a few weeks, and on October 30, 2026 it is applied to all existing projects. Those are announced dates, not proof of what your project does today, so check its settings. Once the change has reached your project, a table you create in public needs an explicit grant before the Data API can see it. Existing tables are not affected. They keep their current grants and stay reachable.
The Securing your API page, updated Nov 19, 2026, says default privileges differ between projects, depending on when the project was created and its Data API settings. So do not assume either way. Check your own project (next section). The change applies to the Data API (what supabase-js, REST and GraphQL calls use). If your app talks to Postgres over a direct connection, such as an ORM or a server with a connection string, it does not apply.
How to check
1. Read the error body
When a grant is missing, PostgREST returns a 42501 error whose hint names the exact statement:
{
"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 tells you which role is missing which privilege. Before you copy it, ask whether that role should reach this table at all. A hint that names anon on a table full of user data is a prompt to stop and think, not an instruction to run.
2. List the current grants on the table
Run this in the SQL Editor, using your real schema and table name. It prints role names and privilege names only:
select grantee, privilege_type from information_schema.role_table_grants where table_schema = 'public' and table_name = 'your_table';
Treat this as a grant listing, not proof of effective access. PostgreSQL says this view lists privileges where the grantor or grantee is a currently enabled role, and that it omits access made available through a grant to PUBLIC. If the role from the error is missing the privilege you need, that is a strong lead. Confirm it with the effective check below before you add a grant.
3. Check the role's effective privilege
Postgres has functions that ask whether a role has a privilege. Use the role and operation from the error. For a column-restricted table, check the specific column too:
select
has_table_privilege('anon', 'public.your_table', 'select') as anon_can_select_table,
has_column_privilege('anon', 'public.your_table', 'some_column', 'select') as anon_can_select_column;
The column check succeeds if the privilege is held for the whole table or granted on that column. If the table is intentionally column-restricted, select only the permitted columns instead of granting access to every column.
4. See what new tables receive by default
Supabase documents this query for the schema-specific default privileges that tables, sequences and functions created by the postgres role in public receive for the three Data API roles:
select
case d.defaclobjtype
when 'r' then 'tables'
when 'S' then 'sequences'
when 'f' then 'functions'
end as object_type,
a.grantee::regrole as role,
string_agg(a.privilege_type, ', ' order by a.privilege_type) as privileges
from pg_default_acl d
cross join lateral aclexplode(d.defaclacl) a
where d.defaclrole = 'postgres'::regrole
and d.defaclnamespace = 'public'::regnamespace
and a.grantee in ('anon'::regrole, 'authenticated'::regrole, 'service_role'::regrole)
group by 1, 2
order by 1, 2;
No rows means there are no matching entries for those roles. It does not prove that new objects are private. The query leaves out global defaults and PUBLIC privileges, including the execute privilege every new function receives through PUBLIC, and it only looks at objects created by the postgres role. PostgreSQL adds per-schema defaults to the global defaults, so audit those and the role that actually creates your tables before you call new objects private. You can also review the Data API settings in the Dashboard (Integrations, then Data API), where the "Automatically expose new tables" setting lives.
How to fix it
Grant the minimum, then keep RLS on
Supabase's guidance is to treat three steps as a unit: grant, enable RLS, add policies. If the grant is missing, Postgres rejects the query before RLS comes into play. Grant only what each role needs, and put the grants in the same migration as the RLS setup.
This is a starting example, not a complete owner-only retrofit. It assumes the table already exists and has a user_id column that holds the signed-in user's ID. Enable RLS first, so no ordinary role can read rows before a policy exists, then add the policy, then grant only the operation the policy covers:
-- 1. Enable RLS first alter table public.your_table enable row level security; -- 2. Add the policy (check existing policy names first) create policy "users can read their own rows" on public.your_table for select to authenticated using (auth.uid() = user_id); -- 3. Grant only what that policy covers grant select on table public.your_table to authenticated;
Before you call the table owner-only, audit what was already there, both permissive and restrictive policies. Applicable permissive policies combine with OR; applicable restrictive policies combine with AND and can narrow that access. An older permissive using (true) policy can still broaden access, and expose other users' rows, unless an applicable restrictive policy prevents it. Remove unwanted old policies and any unwanted grants to anon, authenticated or PUBLIC. If your app also writes, add the insert, update and delete privileges together with their matching policies, not before. Our Row Level Security guide covers the full four-policy pattern and how to test it.
For a table that is meant to be public to signed-out visitors, such as a list of announcements, grant only select to anon:
grant select on table public.your_table to anon;
Pair that with RLS and a read policy that fits the data. A grant by itself does not decide which rows come back, and a select grant is not a write grant.
Why the usual shortcuts are the wrong fix
- Adding a
using (true)policy does not clear a missing-privilege error. The grant is checked first. And once the grant exists, an applicable permissive policy that readsto anon using (true), withselectaccess and no restrictive policy narrowing it, lets signed-out visitors read every row it permits. Use it only for data that is meant to be public. See RLS policies that are always true. - Turning RLS off is not a fix. Supabase says tables and views exposed through the Data API without RLS can be accessed by any role with matching grants. PostgreSQL says that with row security off, all rows are visible and modifiable, subject to the standard SQL privileges. So each role can act on every row, limited only by the operations its privileges allow.
- Granting everything to everyone to make the error stop. Supabase says to grant the minimum privileges each role needs, and a hint names one privilege for one role. Granting every privilege to
anonandauthenticatedon a table that has RLS off lets those roles do whatever those privileges allow on every row. - Switching the browser to the
service_rolekey. That role bypasses RLS and belongs on the server only. A browser bundle that carries it is a different, worse problem. See service_role key exposed.
If you changed the defaults, bundle the grants
If you want new tables to stay private until you grant access, Supabase documents revoking the default privileges so exposure becomes opt-in. After that, a new table in public that your app reaches through the Data API needs explicit grant lines in the same migration as its RLS setup, or the request can return 42501. Tables never accessed through the Data API need no grant for Data API access. Direct Postgres connections are outside this default-change scope. Server-side code using the Data API, including a secret or service_role key, still needs the required SQL privileges for its requesting role. Keep secret keys server-side. Default revokes only affect future objects created by the role you name, and Supabase notes that a revoke limited to one schema cannot remove the execute privilege that new functions receive through PUBLIC.
Existing tables keep their current grants. To remove the named roles' direct grants on an existing table:
revoke all on table public.your_table from anon, authenticated, service_role;
That removes only those direct grants. Before you call the table inaccessible, check for PUBLIC grants and inherited privileges, for example with the has_table_privilege check above. Leave service_role out of the list if its server-side access should stay, and keep the secret key on the server.
Other causes of 42501
Supabase's troubleshooting page lists these besides a missing table grant:
- A forbidden schema. API roles cannot access certain schemas, most notably
authandvault. Those restrictions are intentional. - A custom schema. If you created one, you have to give the Data API permission to query it (Supabase's Using Custom Schemas guide).
- Column-level restrictions. If access is set per column, a query fails with 42501 on a restricted column. That includes
select *, because it expands to every column. - An RLS rule on a write. If
anonorauthenticatedtries to insert or update without the RLS permission to do so, Postgres also returns 42501. If that is your case, read new row violates row-level security policy. - Functions. RLS does not apply to functions, so grant
executeonly to the roles that should call them.
Prove it / common mistakes
- Match the symptom to the layer. A missing required privilege raises 42501. A policy that filters a row out raises nothing and matches zero rows. An empty list on its own does not tell you RLS is the cause, though: the table may be empty, or your request filters may exclude every row. Confirm a known fixture row exists, then check the role, the signed-in identity and the filters.
- Test the grant itself. Supabase's own database test pattern asserts that a missing grant raises 42501. Run
supabase test dbfor the table, as covered in the RLS guide. - Re-run the failing request as the same role, then try it signed out and as a second signed-in user. You should see only the rows you meant to allow.
- Check your migrations. Supabase lists migrations or provisioning flows that create tables in
publicwithout explicitGRANTstatements as something to fix. For tables you want the Data API to reach, bundle the grants with the RLS and policy statements in the same migration. - RLS on with no policies is a different state. For ordinary roles that are subject to RLS, no policy means no rows are visible or modifiable. It is not a complete guarantee: table owners normally bypass RLS, roles with
BYPASSRLSand superusers always do, and whole-table operations such asTRUNCATEare not subject to row security. See RLS enabled, no policy.
Do not trade the error for an open table. An applicable permissive select policy to anon using (true) with select access exposes the rows it permits to signed-out clients. With RLS off, each role can use every row for whatever its effective privileges allow. Fix the missing privilege without broadening access beyond what you intend.
next step
Want a second pair of eyes?
Grab the free Lockdown Pack (security rules for Cursor and Claude Code plus a pre-launch checklist), or have us check your repo with a $99 Scan + Report.
Sources
Sources consulted for this guide are listed below. Check your project's current settings, and test any SQL you adapt, before you deploy it. Last source review: Nov 2026. If behavior changed, the docs below are the source of truth.
- Supabase: Database API 42501 errors (causes, missing table-level privileges, grants query, column-level restrictions, forbidden and custom schemas)
- Supabase: Securing your API (grants and RLS, default privileges, explicit grants, 42501 hint, check and revoke default privileges)
- Supabase changelog: Breaking Change, tables not exposed to Data and GraphQL API automatically (dates, 42501 error body, grant, RLS and policy steps)
- Supabase: Row Level Security (grants and policies, missing grant raises 42501 before any policy, using (true) to anon, test pattern)
- PostgreSQL: Privileges (new objects usable only by the owner until privileges are granted)
- PostgreSQL: Row Security Policies (default-deny with no policy, owners and BYPASSRLS, TRUNCATE, permissive and restrictive policies, RLS off)
- PostgreSQL: ALTER DEFAULT PRIVILEGES (per-schema defaults are added to global defaults)
- PostgreSQL: role_table_grants view (omits PUBLIC grants, table_schema column)
- PostgreSQL: System information functions (has_table_privilege, has_column_privilege)
- PostgreSQL: Error codes appendix (42501 insufficient_privilege)