Thread: pg_connect() unable to connect to pgsql server
pg_connect() unable to connect to pgsql server
From
ATest@sbsdk12.org (Coutts, Ashe (Testing Account))
Date:
Sorry about this -- I know its been asked a bunch and I've read much of what's been posted but I am unable to get my connection working. So ... My goal is to use apache with php to extract and display data from pg. ==== My attempts fail with the following ========= Warning: pg_connect() unable to connect to PostgreSQL server: could not connect to server: Connection timed out Is the server running on host localhost and accepting TCP/IP connections on port 5432? in /usr/www/site.admin/htdocs/sasixp/test.php on line 21 An error occured with the connection. ===== the line 21 in a php script that fails is ===== $database = pg_connect ("host=localhost user=postgres dbname=xbase"); === The next lines comprise the one line that is in my /etc/rc.d/init.d/postgresql file: ============== su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -o -i -D $PGDATA -p /usr/bin/postmaster start > /dev/null 2>&1" < /dev/null === End lines forming /etc/rc.d/init.d/postgresql == So the -i is there, no? OR is it in the wrong place? ===== running "netstat -an | grep 5432" === displays: tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN unix 2 [ ACC ] STREAM LISTENING 9934 /tmp/.s.PGSQL.5432 ==== Line from /var/lib/pgsql/data/pg_hba.conf ======= local all trust ==== Line from /var/lib/pgsql/data/postgresql.conf tcpip_socket = true ============================= I don't understand what to try next. Any suggestions would be GREATLY appreciated "Experience is not what happens to you, it is what you do with what happens to you" -- Aldous Huxley (1894-1963) Ashe Coutts (ashe@sbceo.k12.ca.us) 805.963.7751 Ext 260 Fax 805.884.1557
From: ATest@sbsdk12.org (Coutts, Ashe (Testing Account)) To: pgsql-novice@postgresql.org Date sent: Wed, 20 Nov 2002 15:22:43 -0800 Subject: [NOVICE] pg_connect() unable to connect to pgsql server Are you supplying a valid password and port to the database? ie $connection = pg_connect("host=sheep port=5432 dbname=mary user=lamb password=foo"); There's a php/postgres mailing list which might be more helpful pgsql-php@postgresql.org worth subscribing to Hope this helps Paul Butler ) > Sorry about this -- I know its been asked a bunch and > I've read much of what's been posted but I am unable > to get my connection working. So ... > > > > My goal is to use apache with php to extract and display data from pg. > > ==== My attempts fail with the following ========= > Warning: pg_connect() unable to connect to PostgreSQL server: > could not connect to server: Connection timed out Is the server > running on host localhost and accepting TCP/IP connections > on port 5432? in /usr/www/site.admin/htdocs/sasixp/test.php > on line 21 An error occured with the connection. > > ===== the line 21 in a php script that fails is ===== > $database = pg_connect ("host=localhost user=postgres dbname=xbase"); > > === The next lines comprise the one line that is in my > /etc/rc.d/init.d/postgresql file: ============== > su -l postgres -s /bin/sh -c "/usr/bin/pg_ctl -o -i -D $PGDATA > -p /usr/bin/postmaster start > > /dev/null 2>&1" < /dev/null > === End lines forming /etc/rc.d/init.d/postgresql == > > So the -i is there, no? > OR is it in the wrong place? > > ===== running "netstat -an | grep 5432" === displays: > tcp 0 0 0.0.0.0:5432 0.0.0.0:* LISTEN > unix 2 [ ACC ] STREAM LISTENING 9934 /tmp/.s.PGSQL.5432 > > ==== Line from /var/lib/pgsql/data/pg_hba.conf ======= > local all trust > > ==== Line from /var/lib/pgsql/data/postgresql.conf > tcpip_socket = true > > ============================= > I don't understand what to try next. > Any suggestions would be GREATLY appreciated > "Experience is not what happens to you, it > is what you do with what happens to you" > -- Aldous Huxley (1894-1963) > > Ashe Coutts (ashe@sbceo.k12.ca.us) > 805.963.7751 Ext 260 > Fax 805.884.1557 > > > ---------------------------(end of broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly