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

undefined_object index “…” does not exist — 42704

PostgreSQL error "index "…" 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 an index that does not exist. PostgreSQL raises SQLSTATE 42704 (undefined_object).

  • The named index isn’t defined.
  • Common in DROP INDEX/ALTER INDEX/REINDEX.
  • Index names live in a schema like tables.

What the server log shows

ERROR:  index "idx_orders_customer" does not exist

Why PostgreSQL raises this — what the manual says

the DROP INDEX reference (Description):

“A normal DROP INDEX acquires an ACCESS EXCLUSIVE lock on the table, blocking other accesses until the index drop can be completed.”

Indexes are named schema objects. Referencing a name that doesn’t exist (typo, already dropped, or wrong schema/search_path) cannot be resolved, so PostgreSQL reports 42704.

Common causes

  • A typo or wrong case in the index name.
  • The index was already dropped or never created.
  • It lives in a schema not on the search_path.

How to fix it

  1. List indexes: \di or query pg_indexes.
  2. Use the exact (optionally schema-qualified) index name.
  3. Use DROP INDEX IF EXISTS for idempotency.

Related & next steps

Reference: PostgreSQL 18 — DROP INDEX.

Was this helpful?