Diagnostic Queries
Symptoms
A connection or command referenced a database name that does not exist in the cluster. PostgreSQL raises SQLSTATE 3D000 (invalid_catalog_name).
- Very common at connect time with a wrong/missing dbname.
- Database names are case-sensitive unless created unquoted.
- The default
postgresdatabase may be what you actually need.
What the server log shows
FATAL: database "orders" does not exist
Why PostgreSQL raises this — what the manual says
Chapter 22 Managing Databases:
“Every instance of a running PostgreSQL server manages one or more databases.”
Each database is a catalog entry in pg_database. A connection request or cross-database reference naming a non-existent database cannot be resolved and is rejected with 3D000.
Common causes
- Typo or wrong case in the database name.
- The database was never created (or was dropped).
- Connecting before a provisioning/migration step ran.
How to fix it
- List databases:
\lin psql orSELECT datname FROM pg_database;. - Create it:
CREATE DATABASE orders;. - Fix the connection string’s
dbname(and case).
Related & next steps
Reference: PostgreSQL 18 Section 23 “Managing Databases”.
Thanks — noted. This helps keep the database accurate.