Skip site navigation (1) Skip section navigation (2)

Peer authentication problem in CGI-Perl

From: arifin purba <arifinpurbasigumonrong(at)yahoo(dot)gr>
To: pgsql-novice(at)postgresql(dot)org
Subject: Peer authentication problem in CGI-Perl
Date: 2002-02-13 17:28:35
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
I am writing a CGI-Perl script that connects to
PostgreSQL. For this I use the module Pg. I connect to
PostgreSQL using the command 

Pg::connectdb("dbname=test user=johndoe

but everytime my connection is refused with the

"Peer authentication failed for user 'johndoe'"

The same thing does NOT happen whenever I login from
shell-prompt with psql:

psql -U johndoe -W test /* no problem here */

Neither is it a problem to connect with Pg module in
non-CGI script ("normal" Perl script that runs on

Back to the CGI Script, if I try to connect without
user ID & password (only giving database name) the
error message is, 

Peer authentication failed for user www-data. 

Does this mean I have to create user www-data? Would
the same problem not happen again with user www-data?

Here's my Perl script, please help me:

#!/usr/bin/perl -w

use strict;
use Pg;
use CGI qw(:standard);

my $conn = Pg::connectdb("dbname=test user=johndoe 	

die $conn->errorMessage unless PGRES_CONNECTION_OK eq 

print header, start_html;

my $result = $conn->exec("SELECT surname FROM people 	
WHERE id=10001");

die $conn->errorMessage unless PGRES_TUPLES_OK eq

while(my @row = $result->fetchrow) {
    print @row, "\n";

print end_html;

Thanks beforehand

Do You Yahoo!?
Αποκτήστε τη δωρεάν διεύθυνση σας στο


pgsql-novice by date

Next:From: arifin purbaDate: 2002-02-13 17:28:45
Subject: Peer authentication problem in CGI-Perl
Previous:From: Pam WamplerDate: 2002-02-13 16:03:00
Subject: Cannot log in to DBI

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group