published fresh until

Postgres: relation "users" does not exist—what now?

Summary As of October 2026, check relation lookup before recreating a table; the cited sources establish no general column-error cause or fix (checked 2026-10-28). In the failing session, start with SHOW search_path;

Not for permission denied for schema public, see postgres-15-permission-denied-for-schema-public-migration-fails

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

relation "%s" does not exist

PostgreSQL cannot resolve the relation named by the statement even though it may exist in another schema.

Do first: run SHOW search_path; in the same session that receives the error, before changing the schema or rerunning migrations.

Evidence status: official schema documentation explains unqualified relation lookup; public reports illustrate session and schema mismatches, while the cited sources establish no general column-error cause or fix and no reproduction was run here (checked 2026-10-28).

Not for: PostgreSQL permission denied for schema public; see postgres-15-permission-denied-for-schema-public-migration-fails.

How to inspect relation lookup

1. Check SHOW search_path; on the failing connection. PostgreSQL's schema documentation gives this diagnostic command and explains that the first matching relation in the search path is used. Schema search path (checked 2026-10-28). 2. Confirm the intended database and schema from the application configuration and its migration definitions. The schema docs explain that a connection can access only its selected database. Seeing a table through a different database connection does not prove this session can resolve it. Use a connection's metadata rather than sharing a credential-bearing URL. Database and schema scope (checked 2026-10-28). 3. Compare the intended schema with the actual path. The docs state that an unqualified name fails when no match is found, even if a matching table exists in another schema. Untested experiment: if the intended relation exists in a known schema, qualify its name as schema.table in the failing query. Check through the same application connection that lookup succeeds and selects the intended table. Name qualification is documented; its outcome for this query remains unverified. 4. If the table truly is absent from the intended database/schema, stop treating this as a demonstrated search-path problem. Inspect migration history before proposing any write. The cited search-path guidance does not prove that running a migration is the correct repair. 5. Retry the same statement through the application's own connection handling. Reports below show why success in another session is not enough. Preserve the original error and record whether qualification changed lookup.

Diagnostic: column "%s" does not exist

The opening relation template and this column template are present in PostgreSQL parser source (checked 2026-10-28). The exact source messages are relation "%s" does not exist and column "%s" does not exist. Here %s stands for the name; a client may add an error prefix when displaying the message.

For the column error, first compare the exact failing statement with the intended relation's declared columns. That is a diagnostic review, not a sourced general fix. The cited primary sources do not establish a general cause or repair for this column error; do not automatically apply the relation search-path advice or add a column.

Which problem is established?

ObservationSupported interpretationNext decision
Unqualified relation absent from the pathAnother schema may contain it without resolving hereCheck intended schema and qualification
Qualified relation still failsThe simple unqualified-name explanation is insufficientCheck selected database and actual object definition
Column errorParser emits a distinct diagnosticInspect the query and declared columns; cause not established here

The schema guidance is from PostgreSQL 19 documentation (checked 2026-11-24); error formats were checked separately in the moving master source (checked 2026-10-28). Neither establishes the cause for an unseen query.

Public evidence

  • NinoFloris, a project member, Npgsql issue #2055, 2025-11-29 (checked 2026-10-28): “the set search_path to xxx does not get executed during prepare”. The member explained a reported prepare-time failure when a path change and query were combined. Their guidance applies to that execution order, not every PostgreSQL client.
  • Classic298, Open WebUI issue #31526, 2026-09-28 (checked 2026-10-28): “the tables were created in public”. The report describes reads aimed at a configured schema while migrations created tables elsewhere; the author later reported “fixed in dev” on 2026-10-07 (checked 2026-10-28). This is a specific application report, not a generally available package-version guarantee.

What to test

Repeat the failing query through the actual application connection, including its pool or prepared-statement path. Compare the same session's path with the intended schema and test a qualified reference where appropriate. Confirm that successful lookup selects the intended table, especially where schemas contain identically named objects.

Pitfalls

Checking the path in a separate console and assuming it matches the app; creating duplicate tables to silence a lookup error; adding a schema globally without reviewing who can create objects there. PostgreSQL's docs warn that placing a schema on the path trusts users who can create objects in it.

A prompt to give your agent

Read the linked PostgreSQL schema documentation before guessing from the error. Given this redacted failing SQL and declared schema, propose read-only diagnostics starting with SHOW search_path in the failing session. Separate missing relation from missing column. Do not create objects, run migrations or change a global search path. For a column failure, state that the cited sources do not establish its cause and inspect the actual query before proposing a change. Label any proposed mitigation “Untested experiment” and specify a check using the same statement and connection to confirm the intended relation and columns resolve.

Limits

No SQL was executed and no pool or prepared-statement behavior was tested. The public reports cover particular clients and application configurations; they do not establish prevalence. Relation lookup guidance does not establish a general column-error cause or fix. PostgreSQL 19 docs and moving master source were checked 2026-11-24; older releases were not compared.

Started from a post by @NinoFloris, packaged by the editor. Original post

Subjects

More in documentation

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# Postgres: relation "users" does not exist—what now?
Summary: As of October 2026, check relation lookup before recreating a table; the cited sources establish no general column-error cause or fix (checked 2026-10-28). In the failing session, start with `SHOW search_path;`
Copy for agent
get the whatworks thread postgres-relation-column-does-not-exist-search-path and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread postgres-relation-column-does-not-exist-search-path
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks