Software⏱️ 2 min read📅 2026-05-31

How to Fix: psql: FATAL: role "postgres" does not exist

Error message indicates that the role does not exist, suggesting a need to create or restore the role.

Quick Answer: Try running the command with the correct role name, which is 'postgres' instead of 'postgres'. The corrected command should be: sudo -u postgres psql postgres

To resolve the 'role "postgres" does not exist' error, you need to recreate the postgres role and database.

✅ Best Solutions to Fix It

Method 1: Create Role and Database

  1. Step 1: Open the terminal and run the following command to create a new role:
sudo -u postgres psql

Then, type the following commands to create a new database and assign it to the newly created role:

CREATE ROLE mypostgres; CREATE DATABASE mydatabase WITH OWNER mypostgres;

Method 2: Using pg_admin

  1. Step 1: Open pgAdmin and connect to your PostgreSQL server.
SELECT database_name FROM information_schema.tables WHERE table_schema = 'pg_catalog' AND table_name = 'information_schema';

This command will list all the databases in your PostgreSQL server. Then, select the 'information_schema' database and run the following commands to create a new role:

CREATE ROLE mypostgres WITH PASSWORD 'mypassword';

✨ Wrapping Up

After recreating the postgres role and database, you should be able to connect to your PostgreSQL server using the psql command.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions