PostgreSQL: database "..." does not exist
FATAL: database "<name>" does not existYour role and password were accepted, but there is no database with the name you asked to connect to. Create the database, fix the name in your connection string, or confirm you are pointed at the right server.
What this error means
Connecting to Postgres always means connecting to a specific database inside a cluster. If that database was never created, or the name is wrong, the server rejects the connection before you can run anything.
A frequent trigger is a fresh install, where only postgres, template0, and template1 exist, or an app whose config quietly defaults the database name to the username.
How to fix it
The database was never created
Create it, from SQL or the shell.
CREATE DATABASE myapp;
-- or from the shell:
createdb myappThe name is wrong
List the databases and check the exact spelling.
psql -lYou are connected to the wrong server
The database may exist on a different host or cluster. Confirm the host and port in your connection string.
How to avoid it next time
- Create the app database as part of provisioning, and set the database name explicitly in your connection config.
- Do not rely on the database name defaulting to the username.
Frequently asked questions
Why does it try to connect to a database named after my user?
If you do not specify a database, libpq uses the username as the database name. Set the dbname explicitly to avoid this.
How do I create it from the shell?
Run createdb myapp, or CREATE DATABASE myapp; from a psql session connected to an existing database such as postgres.
Stop struggling with SQL
Use FluentDB, the AI database client for macOS.
Related errors
Part of the PostgreSQL error reference. Last reviewed 2026-07-31.