SQLSTATE 42704 ERROR Class 42: Syntax Error or Access Rule Violation

undefined_object role “…” does not exist — 42704

PostgreSQL error "role "…" does not exist" (SQLSTATE 42704): what it means, common causes, and how to fix it.

PG 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed May 2025 Grounded in source

Diagnostic Queries

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

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

Was this helpful?