RailsでFATAL: Ident authentication failed for user "hoge"が出る
結論
pg_hba.confを変更する必要がある
手順
- psqlを起動
- show hba_file;を実行
- sudo vi /var/lib/pgsql/12/data/pg_hba.conf
- IPv4 local connections の部分をidentからtrustに変更
- 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
設定内容については公式の下記参照
RailsはTCP SocketでPostgresqlにアクセスするため、hostを変更すること