PostgreSQL Setup on openSUSE [Linux] pgAdmin4 Authentication Issue (peer, ident to md5)

These days I decided to start learning SQL and tried installing PostgreSQL on my openSUSE 15.6 machine. In Windows it's just one installer and done. But in Linux, I got totally stuck.
First I added the PostgreSQL repo and managed to run the server using the terminal. Then I needed pgAdmin4 for GUI, but there’s no official package for openSUSE. After searching for a long time I found it on Flatpak and installed it.
When I tried to register my local server in pgAdmin, I got this error:
FATAL: Ident authentication failed for user "postgres"
For hours I couldn’t understand what this meant. Then I found that openSUSE by default uses peer or ident authentication. That means your Linux username must match the PostgreSQL username.
I was logged in as sourav, but trying to connect as postgres, so it kept failing.
The fix I found was to edit the pg_hba.conf file and change the authentication method to md5, restart PostgreSQL, and set a password for the postgres user. After that, everything worked smoothly.
This small struggle taught me so much about how Linux handles permissions and how database authentication really works.
Subscribe to my newsletter
Read articles from Sourav Mahato directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
