Re: pg_connect() unable to connect to pgsql server

From: "paul butler" <paul(at)entropia(dot)co(dot)uk>
To: ATest(at)sbsdk12(dot)org (Coutts, Ashe (Testing Account))
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: pg_connect() unable to connect to pgsql server
Date: 2002-11-21 07:49:59
Message-ID: T5eb1fb7456ac1785b31c3@pcow057o.blueyonder.co.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

From: ATest(at)sbsdk12(dot)org (Coutts, Ashe (Testing Account))
To: pgsql-novice(at)postgresql(dot)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(at)postgresql(dot)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(at)sbceo(dot)k12(dot)ca(dot)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(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Gavin Reade 2002-11-21 15:26:39 Error when creating a char column as primary key
Previous Message Graham Bartlett 2002-11-21 00:49:28 Where can I get the code to set up replication using postgres