# What does 'permission denied for table' mean?

**Short answer:** The role making the request (`anon`, `authenticated` or `service_role`) has no privilege on that table. It's a missing `GRANT`, which is checked before RLS. Grant only the operations your app needs to the role that needs them, and keep RLS on.

*Last updated 2026-11-25 · Reviewed by ProofForge*

## The exact error

```text
permission denied for table profiles
(Postgres code 42501)
```

## Why it happens

- The table was created with SQL or a migration that didn't grant privileges to `anon`/`authenticated`.
- Privileges were revoked earlier to lock the table down.
- The table lives in a schema that isn't exposed to the Data API, or the role lacks `USAGE` on that schema.

## How to fix it

1. Decide which role really needs access. Usually that's `authenticated` only, not `anon`.
2. Grant the minimum operations, then make sure RLS and policies limit which rows they can touch:

```sql
grant usage on schema public to authenticated;
grant select, insert, update on table public.profiles to authenticated;
-- keep RLS on so the grant doesn't expose every row
alter table public.profiles enable row level security;
create policy "own profile" on public.profiles
  for all to authenticated
  using ((select auth.uid()) = id)
  with check ((select auth.uid()) = id);
```

## Check it's fixed

Retry the request as a signed-in user, then as a signed-out visitor. The signed-out request should still be refused or return no rows.

> **Scan box (use the site's ScanBox component):** Check whether your live app has this problem. Paste your URL for a free outside-in scan covering exposed keys, open database rules, CORS and security headers. [Scan my app free →](https://proofforge.live/#scan)

## FAQ

### Is this the same as an RLS error?
No. A GRANT controls whether a role may touch the table at all. RLS then decides which rows. A missing grant gives 'permission denied'; a failed policy gives 'new row violates row-level security policy' or returns zero rows.

### Should I grant to anon?
Only for data that is genuinely public. Anything you grant to `anon` is reachable with the key that ships in your frontend.

### Should I use the service_role key to get around it?
Not in the browser. The service_role or secret key bypasses RLS and must stay on the server.

## Sources

- [PostgreSQL: GRANT](https://www.postgresql.org/docs/current/sql-grant.html)
- [Supabase: Securing your API](https://supabase.com/docs/guides/api/securing-your-api)

## Related

- [Fix 'new row violates row-level security policy' (Supabase)](/errors/new-row-violates-row-level-security-policy)
- [Fix: Supabase RLS disabled](/fix/supabase-rls-disabled)
- [Fix: service_role key exposed](/fix/service-role-key-exposed)
- [Supabase RLS checker](/tools/supabase-rls-checker)
- [All errors](/errors)
