Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

this my configuration:

#postgres.conf:

listen_addresses = 'localhost'

#pg_hba.conf:

local all postgres md5
local all appuser trust
local all devuser trust
local all all peer

i'm connecting in local using the C-Library libpq. My connection string is:

host=localhost user=appuser dbname=mydbname port='5432'

However, unless I have a .pgpass file in the home of my developer user (devuser), (the one who launches the application that is linked with libpq), my executable cannot connect, I receive the error fe_sendauth : no password supplied

As I said, if the .pgpass file is here, then it connects ok.

What I don't understand: I configured local all appuser trust. Why do I need a .pgpass file all the same?

(It's not a serious problem in itself, because later on for security measure, it will no longer be at trust, but md5, so I'll have the .pgpass file anyway. But I'd like to know)

share|improve this question

1 Answer 1

up vote 4 down vote accepted

I can see how one might think listen_addresses = 'localhost' is somehow related to the authentication method local. But it is not. I quote the manual on listen_addresses:

listen_addresses (string)

Specifies the TCP/IP address(es) on which the server is to listen for connections from client applications.

And the chapter The pg_hba.conf File in the manual:

local

This record matches connection attempts using Unix-domain sockets. Without a record of this type, Unix-domain socket connections are disallowed.

Bold emphasis mine.

For connections via localhost (TCP/IP, local loopback) you actually need an entry for the authentication method host in your pg_hba.conf file (not for local).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.