Thread: PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server:
PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server:
From
Abdus Samad Ansari
Date:
PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: I have setup PHP/Postgres and is running fine upto document root i.e. /var/www/html, but when i am calling it through a cgi-bin php file it is giving log error as : [error] [client 127.0.0.1] PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: \x04\xe6\xe3\xbfPF; what may be the solution. --Abdus Samad Ansari
Re: PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server:
From
Tino Wildenhain
Date:
Hi, Abdus Samad Ansari wrote: > PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: > could not connect to server: > I have setup PHP/Postgres and is running fine upto document root > i.e. /var/www/html, but when i am calling it through a cgi-bin php file > it is giving log error as : > [error] [client 127.0.0.1] PHP Warning: pg_connect(): Unable to connect > to PostgreSQL server: could not connect to server: \x04\xe6\xe3\xbfPF; > well there are a couple of checks you could do to find out: 1) decide how to connect - via IP or via unix socket 2) in each of the above see if postmaster is indeed listening to that socket (netstat is your friend) - adjust postgresql.conf and/or start options accordingly. depending on your distribution you might want to enable logging 3) try connection via psql command line client - see if you have matching pg_hba.conf entries 4) try to connect via psql command line client with the same user your script runs (apache in your case) - same as (3) but ident vs. md5 (password) in pg_hba.conf after all you might want to use some pooling layer because pg_connect from cgi can get very expensive (also note that outside of PHP there are a lot possible elegant solutions to that) Tino
Attachment
Re: PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server:
From
"Harald Armin Massa"
Date:
hello, most crucial information is missing, like: - your operating system - your postgresql version - on which computer is your database server running - is your database server running But most likely your problem is that you did not configure PostgreSQL to listen to TCP/IP-requests. Which again makes it most likely that you are using a way outdated PostgreSQL Version (that ist < 8.x) Please update to 8.3.1, and adjust your postgresql.conf, parameter "listen_addresses (string)" accordingly. Best wishes, Harald On Mon, May 12, 2008 at 11:58 AM, Abdus Samad Ansari <ansarias@wbpcb.gov.in> wrote: > PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: > could not connect to server: > I have setup PHP/Postgres and is running fine upto document root > i.e. /var/www/html, but when i am calling it through a cgi-bin php file > it is giving log error as : > [error] [client 127.0.0.1] PHP Warning: pg_connect(): Unable to connect > to PostgreSQL server: could not connect to server: \x04\xe6\xe3\xbfPF; > > what may be the solution. > > --Abdus Samad Ansari > > > > -- > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general > -- GHUM Harald Massa persuadere et programmare Harald Armin Massa Spielberger Straße 49 70435 Stuttgart 0173/9409607 fx 01212-5-13695179 - EuroPython 2008 will take place in Vilnius, Lithuania - Stay tuned!
Re: PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server:
From
Tom Lane
Date:
Abdus Samad Ansari <ansarias@wbpcb.gov.in> writes: > I have setup PHP/Postgres and is running fine upto document root > i.e. /var/www/html, but when i am calling it through a cgi-bin php file > it is giving log error as : > [error] [client 127.0.0.1] PHP Warning: pg_connect(): Unable to connect > to PostgreSQL server: could not connect to server: \x04\xe6\xe3\xbfPF; Hmm, so the most useful part of the error message is getting trashed :-( One possible explanation for that is that you're using a non-thread-safe libpq in a threaded environment. What PG version is your libpq, exactly, and how did you build or obtain it? regards, tom lane
Re: PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server:
From
Andy Anderson
Date:
Abdus Samad Ansari <ansarias@wbpcb.gov.in> writes: > I have setup PHP/Postgres and is running fine upto document root > i.e. /var/www/html, but when i am calling it through a cgi-bin php > file > it is giving log error as : > [error] [client 127.0.0.1] PHP Warning: pg_connect(): Unable to > connect > to PostgreSQL server: could not connect to server: \x04\xe6\xe3\xbfPF; I don't know how the error message is structured, but if "\x04\xe6\xe3\xbfP" refers to the host, perhaps the connection string you are handing to pg_connect() is trashed. What is the actual code you are using for this call? -- Andy
Re: PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server:
From
Alban Hertroys
Date:
On May 12, 2008, at 11:58 AM, Abdus Samad Ansari wrote: > PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: > could not connect to server: > I have setup PHP/Postgres and is running fine upto document root > i.e. /var/www/html, but when i am calling it through a cgi-bin php > file > it is giving log error as : > [error] [client 127.0.0.1] PHP Warning: pg_connect(): Unable to > connect > to PostgreSQL server: could not connect to server: \x04\xe6\xe3\xbfPF; Isn't that the server name it's printing after the message? Seems an odd name for a server... If I enter that in Vim I get "^Dæã¿PF", which doesn't even seem a valid UTF-8 sequence according to my quick checks. > what may be the solution. Alban Hertroys -- If you can't see the forest for the trees, cut the trees and you'll see there is no forest. !DSPAM:737,482930f1927662132392431!
Re: PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server:
From
Abdus Samad Ansari
Date:
The problem is solved, it was the Enhanced Security which was on and creating problem in connecting with postgres thru cgi. Thanks alot! On Mon, 2008-05-12 at 17:55, Tino Wildenhain wrote: > Hi, > > Abdus Samad Ansari wrote: > > PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: > > could not connect to server: > > I have setup PHP/Postgres and is running fine upto document root > > i.e. /var/www/html, but when i am calling it through a cgi-bin php file > > it is giving log error as : > > [error] [client 127.0.0.1] PHP Warning: pg_connect(): Unable to connect > > to PostgreSQL server: could not connect to server: \x04\xe6\xe3\xbfPF; > > > well there are a couple of checks you could do to find out: > > 1) decide how to connect - via IP or via unix socket > 2) in each of the above see if postmaster is indeed listening to that > socket (netstat is your friend) > - adjust postgresql.conf and/or start options accordingly. > depending on your distribution you might want to enable logging > 3) try connection via psql command line client > - see if you have matching pg_hba.conf entries > 4) try to connect via psql command line client with the same user your > script runs (apache in your case) > - same as (3) but ident vs. md5 (password) in pg_hba.conf > > after all you might want to use some pooling layer because pg_connect > from cgi can get very expensive (also note that outside of PHP there > are a lot possible elegant solutions to that) > > Tino -- ---------------------------------------------------------------------- Abdus Samad Ansari "Paribesh Bhawan" 10A, LA Block, Sec III, Salt Lake, Kolkata - 700 098 Phone : 91-033-2335 9829 ----------------------------------------------------------------------