Paul's Programming Notes PostsRSSGithub

Adminer - Unable to connect to PostgreSQL server: FATAL: Peer authentication failed for user

Updated 2026-08-08: explained the cause and replaced the trust line, which hands anyone on the box a superuser login.

This is what I originally suggested putting in pg_hba.conf:

local   all             postgres                                trust

It works, and on a shared or internet-facing machine you should not leave it there. trust means the server accepts the connection with no credentials at all, so any local user (including anything running as the web server) can connect as the postgres superuser just by asking.

The reason the default fails is that Debian and Ubuntu ship local all postgres peer. Peer authentication asks the kernel for the operating system username behind the socket connection and requires it to match the PostgreSQL role being requested. Adminer runs under the web server’s user, usually www-data, so asking for the postgres role fails the match and you get Peer authentication failed for user "postgres".

Password authentication is the fix that doesn’t involve trusting every local process:

local   all             postgres                                scram-sha-256

Then reload with sudo systemctl reload postgresql or SELECT pg_reload_conf(); and give Adminer the password. scram-sha-256 has been the default for password_encryption since PostgreSQL 14; on anything older than 10, use md5. Setting a password on a role that never had one is ALTER ROLE postgres WITH PASSWORD 'something';.

Better still, don’t log into Adminer as the superuser. Create a role that owns only the database you’re browsing, and the blast radius of that password stops there.