次のようにユーザーがある状態でエラーが出る時の対策です。
postgres=# select usename from pg_user;
usename
----------
postgres
scott
(2 rows)
エラーの状況
$ psql -U scott city
psql: error: FATAL: Peer authentication failed for user "scott"
pg_hba.conf を編集します。
/etc/postgresql/14/main/pg_hba.conf
(省略)
#local all all peer
local all all trust
(省略)
PostgreSQL を再起動
sudo systemctl restart postgresql
問題が解決したことを確認
$ psql -U scott city
psql (14.11 (Ubuntu 14.11-0ubuntu0.22.04.1))
Type "help" for help.
city=>