Error
Error Code:
3D000
PostgreSQL Error 3D000: Invalid Catalog Name
Description
This error indicates that the database catalog (or database name) specified in a connection string or SQL command does not exist or is inaccessible. It typically occurs when attempting to connect to a non-existent database or referencing a database that has been dropped or renamed.
Error Message
invalid catalog name
Known Causes
4 known causesNon-existent Database Name
The database name provided in the connection string or SQL query does not correspond to any existing database on the PostgreSQL server.
Typographical Error
A simple typo in the database name within the connection parameters or SQL command prevents the server from finding the intended catalog.
Database Renamed or Dropped
The target database may have been renamed or permanently removed from the PostgreSQL server, making the original name invalid.
Incorrect Case Sensitivity
Although PostgreSQL typically folds unquoted identifiers to lowercase, if a database was created with mixed-case and quoted, then subsequent unquoted references will fail.
Solutions
4 solutions available1. Verify Database Name easy
Check database exists and spelling is correct
1
List all databases
\l
-- or
SELECT datname FROM pg_database;
2
Connect without database first
psql -U postgres
-- Then list databases:
\l
2. Create the Database easy
Create database if it doesn't exist
1
Create database
CREATE DATABASE mydb;
2
Create with owner
CREATE DATABASE mydb OWNER myuser;
3
Create with specific encoding
CREATE DATABASE mydb
WITH OWNER = myuser
ENCODING = 'UTF8'
LC_COLLATE = 'en_US.UTF-8'
LC_CTYPE = 'en_US.UTF-8';
3. Fix Connection String easy
Check database name in connection
1
Verify connection string
# Format:
postgresql://user:password@host:5432/database_name
# Common mistake - wrong database name:
postgresql://user:pass@localhost/myDB # Case matters!
postgresql://user:pass@localhost/mydb # Correct if database is lowercase
4. Restore from Backup medium
Restore database if accidentally dropped
1
Create empty database first
CREATE DATABASE mydb;
2
Restore from pg_dump backup
pg_restore -U postgres -d mydb backup.dump
# or for SQL format:
psql -U postgres -d mydb < backup.sql