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).

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

How to fix it

  1. List roles: \du in psql or SELECT rolname FROM pg_roles;.
  2. Create the role: CREATE ROLE reporting; (add LOGIN/privileges as needed).
  3. Fix the name/case in the statement.

Related & next steps

Reference: PostgreSQL 18 Section 22.1 “Database Roles”.