Cenk Kurtoğlu©26

Supabase "permission denied for table" is usually a GRANT problem, not RLS

“Permission denied for table” reads like an RLS verdict, so people open policies, rewrites, JWT claims — and change nothing. On PostgreSQL 17 I reproduced the exact n8n forum symptom with row level security switched completely off. The gate was a missing GRANT. Same for service_role.

Six modes, three signatures

One table, one row, six configurations, each measuring what the caller gets back. Everything below ran on a local PostgreSQL 17.12 container with roles shaped like Supabase's anon and service_role: a plain login role and a BYPASSRLS one.

ModeSetupSQLSTATESignatureWhat it proves
1RLS disabled, no GRANT, plain role42501permission denied for table agencyPrivilege gate. RLS is not even in the path — there is no grant.
2RLS disabled, no GRANT, BYPASSRLS role42501permission denied for table agencyBYPASSRLS skips policies, not ACLs. service_role without GRANT fails identically.
3RLS disabled, GRANT SELECT00000SELECT OK — 2 rowsThe table was reachable all along. The grant was the gate.
4RLS enabled, policy TO anon_probe, GRANT SELECT00000SELECT OK — rows filtered by policyPolicy + grant together. Neither one alone is the access path.
5RLS enabled, policy TO authenticated, GRANT SELECT as anon_probe00000SELECT OK — 0 rows, no errorThe empty-array signature. The grant lets you ask; the policy set does not include your role.
6GRANT INSERT, sequence not granted42501permission denied for sequence agency_id_seqA serial column needs USAGE on its sequence. This is the n8n 403 'check your credentials' shape — credentials were fine.

Every failure returned 42501. Through PostgREST — including the n8n Supabase node — that surfaces as 403 Forbidden, often with the node's generic “perhaps check your credentials?” hint. The credentials were never the problem in modes 1, 2, or 6.

Why this gets misdiagnosed

“RLS, policies are disabled, credentials all appear correct, but permission denied” is the exact shape of the n8n community thread I measured against. The words “RLS disabled” act as a stop sign: if policies are off, people assume privileges are on. In PostgreSQL the two gates are independent:

The expensive corollary: a project can run with relrowsecurity = false on a table and still be reachable— mode 3 proves the grant alone was the only gate. “RLS is disabled” is not a safety statement and it is not an error explanation.

The empty-array signature (mode 5)

The quieter failure has no error at all. A role that holds SELECTbut is not named by any policy gets a successful query and zero rows. From n8n that looks like “node returns empty” — workflows downstream of it branch on emptiness and silently do nothing. That signature is a grant-plus-policy mismatch: the grant let you ask, the policy set does not include you.

Mode 6 is the insert-side twin. GRANT INSERT on the table does not carry the sequence a serial column calls. The insert fails with permission denied for sequence— after the table-level grant “succeeded.” Sequences carry their own ACL.

The 30-second diagnostic

Run these read-only queries as the project role before touching a single policy. Each one separates a gate:

QueryWhat it tells youMeasured result
has_table_privilege('anon','public.agency','SELECT')Whether the role can even open the tablet after grant / f before — the first gate, before any policy
select grantee, privilege_type from information_schema.role_table_grants where table_name = 'agency'Who actually holds what on this tableanon_probe: INSERT, SELECT — and nothing else
select relrowsecurity from pg_class where relname = 'agency'Whether policies are in the path at allt / f — a table can serve traffic with policies off
select polname, polcmd::text, (select string_agg(r.rolname,',') from pg_roles r where r.oid = any(p.polroles)) from pg_policy p join pg_class c on c.oid = p.polrelid where c.relname = 'agency'Which roles each policy applies toempty polroles = PUBLIC — the policy covers every role
select * from pg_default_aclWhat future tables inherit0 rows in a fresh project — the next table starts ungranted

has_table_privilege answers the mode-1 question in one call. If it returns f, stop reading policies — you are looking at the wrong gate.

The fix, in gate order

  1. Grant the table. grant select, insert, update, delete on public.agency to anon, authenticated; — whatever the surface actually needs, no more.
  2. Grant the sequence. grant usage, select on all sequences in schema public to anon, authenticated; — without it, inserts with a serial/bigserial default die at mode 6.
  3. Only then look at policies.Check the policy's roles: empty polroles means PUBLIC (every role), a named list means everyone else gets the mode-5 empty array.
  4. Set default privileges before the next table. alter default privileges in schema public grant select on tables to anon; — my fresh container had pg_default_acl empty, so the next migration inherits nothing and repeats mode 1.

Honest limits of these measurements

What this has to do with RLS reviews

The drift monitor I publish free checks the other direction — policies that exist but do not protect (owner bypass, USING (true), missing WITH CHECK). Modes 1–6 here are the missing-grant direction. A complete picture needs both: who can reach a table, and which rows they actually see once inside.

The free drift monitor checks thirteen read-only catalogue conditions nightly and alerts only on changes from your own baseline. The $95 spot check is when you want a second pair of eyes on exactly these signatures before you touch production.

Prefer the verdict instead of running the toolkit yourself?

Fixed-price reviews with the evidence, the SQL and the written verdict. Fixes are quoted separately. Instant checkout, no account needed.

Want the free first step? The RLS Drift Monitor runs 13 read-only catalog checks on a schedule. It never reads application rows; zero findings is not proof of safety.

Prefer escrow? $49 drift monitor setup or $95 exposed-key triage on Upwork. Work starts only after the fixed-price milestone is funded.

Work starts only after payment is secured. Catalogue checks are read-only; no write credentials, no service_role key, no application rows.

Free entry

If you would rather run these checks yourself

Honest limit: a catalog check is not proof of a leak, and an empty log is not proof the key was never used. Zero findings does not mean safe. If you want a human: $29 self-run kit · $95 spot check (five tables, one working day) · $195 full audit — work starts only after payment is secured.

Template bundle

Review all 20 frontend starters in one bundle

20 editable frontend starters with live demos are $79 — one payment, no subscription.

View the Bundle — $79↗