psycopg.errors.UndefinedColumn: column "titel" does not exist

Python · updated 2026-11-10

Raised by Postgres (SQLSTATE 42703) when a query names a column the table does not have. psycopg raises UndefinedColumn, Django and SQLAlchemy wrap it as ProgrammingError, node-postgres throws it with code 42703. Postgres often adds a HINT such as Perhaps you meant to reference the column "todos.title".

Traceback (most recent call last):
  ...
psycopg.errors.UndefinedColumn: column "titel" does not exist
LINE 1: select titel from todos
               ^
HINT:  Perhaps you meant to reference the column "todos.title".

Quick fix

Read the HINT first: it usually names the column you meant. If the name is right, check its case: an unquoted createdAt is looked up as createdat, so a column created as "createdAt" must be quoted in raw SQL. If the column really is missing, the migration that adds it has not run on this database.

  1. Read the HINT line under the error; Postgres suggests the closest existing column.
  2. Compare case: unquoted names are lowercased, so camelCase columns need double quotes in raw SQL.
  3. List the real columns: \d tablename in psql, or select column_name from information_schema.columns where table_name = 'todos'.
  4. If the model has the field and the table does not, run the pending migration on this database.
  5. In a string literal mix-up (where name = "alice"), double quotes mean a column: use single quotes for values.

Why it happens

Model ahead of the database

A new field was added to the model or query and deployed, but the migration that adds the column never ran there.

Case folding

A camelCase column created with quotes ("createdAt") is not found by unquoted SQL, which looks for createdat.

Double quotes around a value

where name = "alice" asks for a column named alice. String values take single quotes.

Typo or a renamed column

The query still uses an old or misspelled name; the HINT usually shows the right one.

Other fixes

  • Use query parameters instead of building SQL strings, which also removes the quote mix-up.
  • Keep migrations in the deploy step so code and schema change together.

Same error, other wording

  • error: column "createdat" does not exist
  • django.db.utils.ProgrammingError: column app_order.status does not exist
  • psycopg2.errors.UndefinedColumn: column "alice" does not exist

Let your coding agent catch the next one

Runheed records this error in production with the stack trace, the breadcrumbs before it and, when you set it, the agent session that shipped the code, and serves it to Claude Code, Cursor or any MCP client. With it connected, you can ask:

> Find the "column does not exist" errors, read each hint, and fix the query, the quoting or the missing migration so the code and the table match.

Setup for Python and FastAPI, Django or Flask, then have your agent fix and resolve it.

Related errors

More in Databases

References: PostgreSQL docs: identifiers and case folding, PostgreSQL docs: error codes (42703 undefined_column)

Spotted a mistake? Email hello@greatwork.company. About Runheed.