Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have read multiple articles detailing this fix for this exact issue. I have tried all kinds of variations of editing the pg_hba.conf file but no luck I still get the following error in my Apache log when I attempt to run the php program I'm trying to use.

Thu Mar 28 08:20:21 2013] [error] [client 172.16.1.64] PHP Warning: pg_connect(): >Unable to connect to PostgreSQL server: FATAL: Peer authentication failed for user

This is my current pg_hba.conf file:

Imgur

I don't know what else to try, any help is greatly appreciated!

Thanks!

share|improve this question
    
It seems, that only postgresql is allowd to login. Is it correct or do you use another user in you php script? –  prophecy201 Mar 28 '13 at 13:44
    
I have a user that is called focus that has all rights to all tables. I built a basic connection and query script that queries the top 10 results from a table in the database. So I know it works like that. But yes I would like to allow the focus user to login from php with the app I'm using. (custom app, not a standard Wordpress or anything) How would I go about editing the config file to add focus to the allow? Thanks –  Acid Burn 85 Mar 28 '13 at 14:08

1 Answer 1

up vote 0 down vote accepted

Consider the first rule in the pg_hba.conf:

local all all peer

It means that for all local connections, the Unix user should be the same as the db user. Obviously this is not the case for you php code, hence the failure Peer authentication failed for user....

The second rule would let your script connect, but it's ignored because the first rule takes precedence:

local all all trust

This rule means that all local connections are allowed without requiring password and without checking any identity.

If that's OK with you, just delete the first rule, and reload the postgresql service for the change to take effect.

The other rules should not be relevant to the problem since they're related to TCP connections, and according to the error message, that's not that the method used by your script, it's trying to connect through the default Unix domain socket.

share|improve this answer
    
This worked perfect! Thank you so much! –  Acid Burn 85 Mar 29 '13 at 2:11

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.