SQLSTATE 42501Severity mediumLab verified

Incident brief

Permission denied

A role tried to use a table it has not been granted privileges on. PostgreSQL denied the action instead of falling back to the owner's or a broader role's access.

Reproduced on PostgreSQL 16.14Verified 2026-07-15 (Docker lab, PostgreSQL 16.14)Reviewed by Verified against PostgreSQL 16.14 in an isolated lab environment

In 10 seconds

What
Permission denied
What triggers it
Create a table as its owner, then switch to a role with no privileges granted on it.
The fix
GRANT the specific privilege (e.g. SELECT) on the table to the role that needs it.
Proof
Reproduced on PostgreSQL 16.14 → A role with no privileges on a table was rejected with SQLSTATE 42501 when it tried to SELECT from it. The table's data was confirmed unaffected afterward.

The fix

What to do right now

The immediate, application-level response to this error.

  • GRANT the specific privilege (e.g. SELECT) on the table to the role that needs it.
  • Grant only what's needed — column-level GRANTs are available if a role should see some columns but not others.
  • Don't assume ALTER DEFAULT PRIVILEGES retroactively fixes access to existing tables — see the premium test for its actual scope.
Fix — SQL
GRANT SELECT ON vault.secrets TO analyst;

Related & next steps

Follow the thread

Everything this error touches — jump straight to the sibling error, term, runbook, or parameter.

Verification

PG 16.14
Last verified
2026-07-15 (Docker lab, PostgreSQL 16.14)
Reviewed by
Verified against PostgreSQL 16.14 in an isolated lab environment
Audit status
reviewed