PostgreSQL error: relation does not exist

ERROR:  relation "users" does not exist
LINE 1: SELECT * FROM users;
                      ^

PostgreSQL found no table, view or sequence with that name among the schemas it is allowed to look in. In practice this error rarely means the table is missing — it usually means you and PostgreSQL are looking in different places.

What this error means

"Relation" is PostgreSQL's umbrella term for tables, views, sequences, indexes and friends. Name resolution depends on two pieces of context people forget they have: the current database (relations live per-database; there is no cross-database access) and the search_path, the ordered list of schemas an unqualified name is resolved against.

Plus one syntax rule that generates endless confusion: unquoted identifiers fold to lowercase. A table created as "Users" (quoted, by an ORM or a GUI) can only ever be reached as "Users" — the unquoted name users is a different identifier.

Common causes

How to diagnose it

SELECT current_database();
SHOW search_path;

-- La relation esiste da qualche parte, sotto qualunque case?
SELECT n.nspname AS schema, c.relname, c.relkind
FROM pg_class c
JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relname ILIKE '%users%';

That last query settles it in one shot: it tells you whether the relation exists at all, in which schema, and with what exact casing.

How to fix it