fatal role does not exist

How to Fix PostgreSQL Error : Fatal: Role Does not Exist

PostgreSQL is a popular database used by many organizations and database developers. Sometimes you may get an error saying ‘Fatal: Role Does not Exist’. This error can prevent you from executing most PostgreSQL commands that involve creating or modifying your data. In this article, we will learn how to fix this issue.

How to Fix PostgreSQL Error : Fatal: Role Does not Exist

One of the simple ways to fix this problem is to login using postgres database user and then run the command where you get the error.

For example, let us say you got this error when you logged into PostgreSQL as test_user user and ran the following command.

create database testdb;

Now login to PostgreSQL database using postgres user. You will be asked for password, enter it to login.

sudo -u postgres -i

Then try running the above ‘create database’ command again. It should work now. Once you are done performing required operations, quit PostgreSQL by entering exit command.

If the above approach does not work, try creating your owner user test_user as postgres with sudo.

sudo -u postgres createuser test_user

If this method also does not work, assign superuser role to your user using the following commands. Login to PostgreSQL as postgres administrator user.

sudo su - postgres

psql template1

Create superuser role for your user test_user.

CREATE ROLE test_user superuser

Then create user.

CREATE USER test_user; 

Assign root privilege to user.

GRANT ROOT TO test_user;

Enable login for that user, so you can run your commands from terminal.


In this article, we have learnt how to fix ‘fatal role does not exist’ error in PostgreSQL.

Also read:

How to Install Python Package Using Script
How to Iterate Over List in Chunks
How to Create Python Dictionary from String
How to Strip HTML from Text in JavaScript
How to Preload Images With jQuery

Leave a Reply

Your email address will not be published.