Solve the PostgreSQL Error "psql: FATAL: database "root" does not exist"

Learn how to solve the common PostgreSQL error psql: FATAL: database "root" does not exist." New PostgreSQL users often encounter this error when first logging in to PostgreSQL.


  • A Cloud Server running Linux (any distribution)
  • PostgreSQL installed and running

vServer (VPS) from IONOS

Low-cost, powerful VPS hosting for running your custom applications, with a personal assistant and 24/7 support.

100 % SSD storage
Ready in 55 sec.
SSL certificate

Switch to the PostgreSQL user

If you have used MySQL/MariaDB in the past, you may be accustomed to logging into the database with the command mysql -u root -p from any account. However, PostgreSQL uses a different security model.

PostgreSQL has its own user on the system which is created when PostgreSQL is installed. The postgres user is able to log into PostgreSQL without using a password. No other user is able to log into PostgreSQL.

This means that before using PostgreSQL, you will need to switch to that user account with the command:

su - postgres

You will then be able to log into the PosgreSQL client with the command:


You will not be able to access the database from the command line as any other user.

What the error means

When you log into PostgreSQL as any user other than the postgres user, it will attempt to log you into a database of the same name as your user account. This means that if you try to use the psql command as root, it will try to log you into the database root. If you try to log in while signed on as jdoe it will look for the database jdoe, and so forth.

Unable to find this database, PostgreSQL gives the error message that "database [your username] does not exist."

We use cookies on our website to provide you with the best possible user experience. By continuing to use our website or services, you agree to their use. More Information.