I want to access postgres with the www-data user. The command are launched by cli.
My program need to be able to launch this command :
psql --username www-data --host=127.0.0.1 --dbname=dbname
It work perfectly if I remove the --host=127.0.0.1, unfortunately I use a third party program for this command and I can change it.
My pg_hba.conf is standard local all postgres peer
# TYPE DATABASE USER ADDRESS METHOD
# "local" is for Unix domain socket connections only
local all all peer
#host all www-data 127.0.0.1/32 md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
In postgresql.conf I put
listen_addresses = '*'
Yes it's insecure but I am testing everything. Still doesn't work
In the .pgpass
127.0.0.1:5432:*:www-data:password
I tried all method : peer, ident, md5, password, I had the error everytime.
The error message (in French) :
FATAL: authentification par mot de passe ?chou?e pour l'utilisateur << www-data >>
mot de passe récupéré dans le fichier fichier « /var/www/.pgpass »
It means that the authentication by password failed for user www-data. It also reports that it was able to recover the password from pgpass (/var/www/.pgpass).
Thanks for you help, I have no idea what to do.