By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,722 Members | 1,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,722 IT Pros & Developers. It's quick & easy.

Postgresql connection problem on SUSE-9.1

P: n/a
I'm running PHP-4.3.4 and Postgresql 7.4.2 on SUSE-9.1. I have this piece of
PHP:

<?php
$c = pg_connect("user=derek dbname=webcalendar");
?>

which produces this error in the browser:

Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT
authentication failed for user "derek" .
in /home/derek/public_html/misc/testpg.php4 on line 3

And yet, from the command line, it works OK:
psql -U derek -d webcalendar

Welcome to psql 7.4.2, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

webcalendar=# \dt
List of relations
Schema | Name | Type | Owner
--------+--------------------------+-------+-------
public | webcal_asst | table | derek
public | webcal_categories | table | derek
public | webcal_config | table | derek
....

There is no password to access this DB, but adding password='' to the
connection string didn't help. The postgresql error log contains the
message: '2004-10-18 13:47:26 FATAL: IDENT authentication failed for user
"derek"'.

Can anyone tell me what I'm doing wrong?
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Derek Fountain wrote:
I'm running PHP-4.3.4 and Postgresql 7.4.2 on SUSE-9.1. I have this piece of
PHP:

<?php
$c = pg_connect("user=derek dbname=webcalendar");
?>

which produces this error in the browser:

Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT
authentication failed for user "derek" .
in /home/derek/public_html/misc/testpg.php4 on line 3

And yet, from the command line, it works OK:

psql -U derek -d webcalendar


Welcome to psql 7.4.2, the PostgreSQL interactive terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

webcalendar=# \dt
List of relations
Schema | Name | Type | Owner
--------+--------------------------+-------+-------
public | webcal_asst | table | derek
public | webcal_categories | table | derek
public | webcal_config | table | derek
...

There is no password to access this DB, but adding password='' to the
connection string didn't help. The postgresql error log contains the
message: '2004-10-18 13:47:26 FATAL: IDENT authentication failed for user
"derek"'.

Can anyone tell me what I'm doing wrong?

try adding host=localhost to the connect string. This forces the use of
tcp/ip connections. It *might* work (:

Steve
Jul 17 '05 #2

P: n/a
ljb
no****@example.com wrote:
I'm running PHP-4.3.4 and Postgresql 7.4.2 on SUSE-9.1. I have this piece of
PHP:

<?php
$c = pg_connect("user=derek dbname=webcalendar");
?>

which produces this error in the browser:

Warning: pg_connect(): Unable to connect to PostgreSQL server: FATAL: IDENT
authentication failed for user "derek" .
in /home/derek/public_html/misc/testpg.php4 on line 3

And yet, from the command line, it works OK:
psql -U derek -d webcalendar


I think: your PostgreSQL pg_hba.conf is set to use "ident" authentication,
where the ident protocol is used to verify the identity of the connection.
When running through the web server, the web server's user ID (something
like "nobody", usually) is returned, which does not match your claimed
username (user=derek). From command line, you are probably logged in as
yourself so ident verifies it is you.

Consider switching from ident to password-based (md5) authentication and
supplying passwords when connecting. If you stick with ident, you probably
need a database account for the web server's username.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.