PostgreSQL: role "..." does not exist
FATAL: role "<name>" does not existPostgres could not find a login role matching the username you connected with. Either the role was never created, was dropped, or the name is misspelled. Create the role, or connect as one that already exists.
What this error means
A role in Postgres is a user or group that can own objects and log in. When you connect, Postgres looks up the username you passed and, if there is no role with that exact name, it refuses the connection with this FATAL error before you can run anything.
A very common trigger is a fresh install: initdb creates a superuser role named after the OS user that ran it, plus the built-in postgres role, and nothing else. If your app connects as a different user, that user does not exist yet.
How to fix it
The role was never created
Create it. Add LOGIN so it can open connections, and only add SUPERUSER if it genuinely needs it.
CREATE ROLE myuser WITH LOGIN PASSWORD 'a-strong-password';You just want to connect as an existing role
The postgres superuser role almost always exists after install. Connect as that to get in.
psql -U postgres -h localhostThe username is misspelled
List the roles Postgres knows about and check the exact spelling and case.
\du
-- or, as SQL:
SELECT rolname FROM pg_roles ORDER BY 1;A restore references an owner role that does not exist
pg_restore tries to set object ownership to roles from the source database. Create those roles first, or restore without ownership.
pg_restore --no-owner -d mydb mydump.dumpHow to avoid it next time
- Provision the app's database role as part of your setup or migration scripts, so a fresh environment always has it.
- Keep the connecting username in one place (an env var), so a typo cannot creep into some code paths and not others.
In the connection path this is SQLSTATE 28000. Running DROP ROLE or ALTER ROLE on a missing role instead raises 42704 (undefined_object).
Frequently asked questions
Why does this happen right after installing PostgreSQL?
initdb only creates the postgres role and one superuser named after the OS user. Any other username your app uses has to be created before it can connect.
What is the difference between a role and a user in Postgres?
They are the same object. A user is just a role created with the LOGIN attribute. CREATE USER is shorthand for CREATE ROLE ... LOGIN.
How do I list all roles?
Run \du in psql, or query SELECT rolname FROM pg_roles; They show every role and its attributes.
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.