Search code examples
postgresqlpg

Postgres: Unable to connect to server. role 'postgres' does not exist


I am new to PostgreSQL and I just have installed pg4admin. I have found out that there are no servers, so I tried to create one, but end up with error shown on the attached screenshot.

By the way, I am able to:

sudo -i -u postgres
psql
\du 

and see:

 Role name |                         Attributes                         | Member of 
-----------+------------------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

enter image description here

I will appreciate any help related to the solution regarding creating PostgreSQL server.


Solution

  • I'm not sure if only one of the things that I did helped or both are required, but here is what I have done:

    • changed port to 5433 (this seems to be something for sure needed, but I have tried this before with no luck)
    • I created a new role and a new OS user with the same name as the role.

    With this two it worked for me.