Re: Unable to connect to PostgreSQL server via PHP

From: "John Coulthard" <bahhab(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Unable to connect to PostgreSQL server via PHP
Date: 2007-08-13 09:05:54
Message-ID: BAY121-F16F704DA9FCE6033AA7397CFDC0@phx.gbl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

The part of the php code for the connection is

$dbconn=pg_connect( "dbname=lumbribase host=localhost port=5432
user=postgres password=$PG_PASS" );
if ( ! $dbconn ) {
echo "Error connecting to the database !<br> " ;
printf("%s", pg_errormessage( $dbconn ) );
exit(); }

This code works on zeldia
http://zeldia.cap.ed.ac.uk/Lumbribase/search_id.php
but not on xyala http://xyala.cap.ed.ac.uk/Lumbribase/search_id.php

So it's something to do with the way xyala is set up. I'm sure I'm missing
something obvious but what..?

It's not a firewall issue because it persists when the iptabes are off.

What does "could not connect to server: Permission denied" mean? Have I
done some something as root or me that I should have done as user postgres?

Thanks

>From: Julio Cesar Snchez Gonzlez <knowhow(at)sistemasyconectividad(dot)com(dot)mx>
>To: John Coulthard <bahhab(at)hotmail(dot)com>
>CC: pgsql-general(at)postgresql(dot)org
>Subject: Re: [GENERAL] Unable to connect to PostgreSQL server via PHP
>Date: Fri, 10 Aug 2007 22:50:47 -0500
>
>El jue, 09-08-2007 a las 14:51 +0000, John Coulthard escribi:
> > Hi
> >
> > I'm trying to set up a new webserver running php and pgsql. PHP was
> > connecting to postgres but I needed to install the php-gd module and now
>I
> > get the error...
> >
> > "PHP Warning: pg_connect() [<a
> > href='function.pg-connect'>function.pg-connect</a>]: Unable to connect
>to
> > PostgreSQL server: could not connect to server: Permission denied\n\tIs
>the
> > server running on host &quot;localhost&quot; and accepting\n\tTCP/IP
> > connections on port 5432?"
> >
> > .... and I'm at a loss can anyone tell me why it's not connecting?
> >
> > Thanks
> >
> > This bit's I know are...
> > http://xyala.cap.ed.ac.uk/php_info.php say's php's configured for pgsql
> >
> > [#(at)xyala]# telnet localhost 5432
> > Trying 127.0.0.1...
> > Connected to localhost.localdomain (127.0.0.1).
> > Escape character is '^]'.
> > Connection closed by foreign host.
> > [#(at)xyala]#
> >
> >
> > [#(at)xyala]# less /var/lib/pgsql/data/pg_hba.conf
> > # TYPE DATABASE USER CIDR-ADDRESS METHOD
> >
> > # "local" is for Unix domain socket connections only
> > #local all all ident sameuser
> > local all all trust
> > # IPv4 local connections:
> > #host all all 127.0.0.1/32 ident sameuser
> > host all all 127.0.0.1/32 trust
> > # IPv6 local connections:
> > #host all all ::1/128 ident sameuser
> > host all all ::1/128 trust
> >
> > [#(at)xyala]# grep 'listen' /var/lib/pgsql/data/postgresql.conf
> > # "pg_ctl reload". Some settings, such as listen_address, require
> > #listen_addresses = 'localhost' # what IP interface(s) to listen on;
> > listen_addresses = '*'
> > [#(at)xyala]#
> >
> > [#(at)xyala]# less /etc/php.d/pgsql.ini
> > ; Enable pgsql extension module
> > extension=pgsql.so
> >
> > the server I'm going to replace is running the same versions of PHP and
> > postgres http://zeldia.cap.ed.ac.uk/php_info.php
> > The /etc/php.ini files on the two machines are the same and the
> > /var/lib/pgsql/data/postgresql.conf files are only different because
>I've
> > set listen_addresses = '*' on the new server (xyala) to see if I can
>make it
> > work.
> >
> > _________________________________________________________________
> > Express yourself instantly with MSN Messenger! Download today it's FREE!
> > http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
> >
> >
> > ---------------------------(end of broadcast)---------------------------
> > TIP 5: don't forget to increase your free space map settings
>
>
>show your php source code for help you.
>
>
>--
>Regards,
>
>Julio Cesar Snchez Gonzlez
>www.sistemasyconectividad.com.mx
>blog: http://darkavngr.blogspot.com
>
>---
>Ahora me he convertido en la muerte, destructora de mundos.
>Soy la Muerte que se lleva todo, la fuente de las cosas que vendran.
>

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message hubert depesz lubaczewski 2007-08-13 09:29:58 Re: UDFs
Previous Message Martijn van Oosterhout 2007-08-13 08:42:52 Re: UDFs