とりあえずコード書けよ

技術的なことの備忘録。

RailsでFATAL: Ident authentication failed for user "hoge"が出る

結論

pg_hba.confを変更する必要がある

手順

  1. psqlを起動
  2. show hba_file;を実行
  3. sudo vi /var/lib/pgsql/12/data/pg_hba.conf
  4. IPv4 local connections の部分をidentからtrustに変更
  5. postgresqlを再起動

変更箇所について

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust #identからtrustに
# IPv6 local connections:
host    all             all             ::1/128                 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            ident
host    replication     all             ::1/128                 ident

設定内容については公式の下記参照

www.postgresql.jp

RailsTCP SocketでPostgresqlにアクセスするため、hostを変更すること