role “…” does not exist
SQLSTATE 42704 condition undefined_object class 42 — Syntax Error or Access Rule Violation severity ERROR
Reproduced & verified on PostgreSQL 14.23, 15.18, 16.14, 17.10 and 18.4 — identical message on every version.
Last reviewed 30 May 2025 · Reproduced live with the SQL on this page.
Symptoms
A statement referenced a role (user/group) that does not exist in the cluster. PostgreSQL raises SQLSTATE 42704 (undefined_object).
- Common in GRANT/ALTER/SET ROLE referencing a missing role.
- Also appears when connecting as a role that was never created.
- Role names are case-folded unless quoted.
What the server log shows
ERROR: role "reporting" does not exist
Why PostgreSQL raises this — what the manual says
Chapter 21 Database Roles:
“PostgreSQL manages database access permissions using the concept of roles.”
Roles live in the shared catalog pg_authid/pg_roles. When a command names a role that is not present, PostgreSQL cannot resolve it and reports 42704.
Common causes
- Typo or wrong case in the role name.
- The role was dropped or never created.
- Granting to a role that exists only in another cluster.
How to fix it
- List roles:
\duin psql orSELECT rolname FROM pg_roles;. - Create the role:
CREATE ROLE reporting;(add LOGIN/privileges as needed). - Fix the name/case in the statement.
Related & next steps
Reference: PostgreSQL 18 Section 22.1 “Database Roles”.