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

undefined_table logical replication target relation “….” does not exist — 42P01

PostgreSQL error “logical replication target relation “….” does not exist — 42P01″ (SQLSTATE 42P01): what it means, common causes, and how to fix it.

PG 10, 11, 12, 13, 14, 15, 16, 17, 18 Official docs
Last reviewed Jun 2026 Grounded in source

Diagnostic Queries

Symptoms

Logical replication apply could not find the target relation that a publication is streaming changes for. PostgreSQL raises SQLSTATE 42P01 (undefined_table).

  • The subscriber is missing the target table.
  • Common when schema isn’t synced to the subscriber.
  • Apply stalls until the table exists.

What the server log shows

ERROR:  logical replication target relation "public.orders" does not exist

Why PostgreSQL raises this — what the manual says

As Chapter 29 Logical Replication explains:

Logical replication delivers changes to tables that must already exist on the subscriber with a matching schema-qualified name and compatible columns — create the missing target table on the subscriber before replication can apply rows to it.

The apply worker maps each replicated change to a local relation by name. If the subscriber lacks that table (schema not migrated), the mapping fails and PostgreSQL reports 42P01, pausing apply.

Common causes

  • The table’s DDL was not created on the subscriber.
  • A schema/table-name mismatch between publisher and subscriber.
  • A table added to the publication but not yet to the subscriber.

How to fix it

  1. Create the matching table on the subscriber (DDL is not replicated).
  2. Keep publisher and subscriber schemas in sync via migrations.
  3. After creating the table, the apply worker resumes automatically.

Related & next steps

Reference: PostgreSQL 18 Section 31 “Logical Replication”.

Was this helpful?