From: vince@weaktight.com
To: Gavin M. Roy <gmr@ehpg.net>
Cc: pgsql-php@postgresql.org
Subject: Re: PHP/postgreSQL
Date: Sat, 04 Feb 2006 18:54:15 -0500
Message-ID: <20060204185415.f2fi0trmogg0880k@webmail.weaktight.com> (raw)
In-Reply-To: <1FC4E0E4-F55C-4308-8493-5680FEBD797E@ehpg.net>
References: <20060204171435.7lfphylyooggs08c@webmail.weaktight.com>
<1FC4E0E4-F55C-4308-8493-5680FEBD797E@ehpg.net>
So the setup is as follows:
I have a web server hosted by stormweb that runs the PHP scripts. On
one of my
local machines behind a router, I have a postgreSQL server service setup.
If I run pgAdminIII on the postgreSQL server machine using the external IP to
connnect (24.85.82.xxx), it works ONLY with these postgreSQL server settings:
>> # TYPE DATABASE USER CIDR-ADDRESS METHOD
>> host all all 0.0.0.0/0 trust
(I believe this is the setting that makes "sure pgsql is listening on tcp/ip")
I have enabled port forwarding on my router to forward 5432 to the proper
machine. Additionally, when I was starting, I was not able to connect from my
local server machine to itself via 24.85.82.xxx until I allowed the 5432 port
to pass through the window's firewall. (I've tried disabling that as well)
Given that it connects, can I assume that it's taking an external route to get
there and that shaw is allowing this traffic? (otherwise the firewall wouldn't
have any effect?)
Are there any possible problems from the web server machine that might be
preventing the connection?
Quoting "Gavin M. Roy" <gmr@ehpg.net>:
> Are you sure your isp isn't blocking access? First thought to come
> to mind is shaw cable might be blocking port 5432. Can you try and
> telnet to the box from your server on port 5432? Also check to make
> sure pgsql is listening on tcp/ip. Also if you're a home shaw
> customer, are you behind a nat router? Have you opened up access on
> the nat router to get to your box behind it?
>
> HTH,
>
> Gavin
>
> On Feb 4, 2006, at 2:14 PM, vince@weaktight.com wrote:
>
>> I'm running PHP/mySQL via a web hosting service. I require my PHP
>> scripts to
>> access an external PostgreSQL database.
>>
>> I have the PostgreSQL server setup to accept connections from anyone:
>> [pg_hba_conf]
>>
>> # TYPE DATABASE USER CIDR-ADDRESS METHOD
>> host all all 0.0.0.0/0 trust
>>
>> [--]
>>
>> I've tested this connection via pgAdminIII and I'm able to connect
>> using this
>> IP, but when I try to connect via php from the hosted webpage...
>>
>> My php script is simple:
>>
>> <?php
>> $conn_string = "host=24.85.82.xxx port=5432 dbname=PGSQL1 user=postgres
>> password=xxx";
>>
>> $dbconn = pg_connect($conn_string);
>>
>> if ($dbconn) {
>>
>> print "Successfully connected to: " . pg_host($dbconn) . "<br/>\n";
>>
>> } else {
>>
>> print pg_last_error($dbconn);
>> exit;
>> }
>>
>> pg_close($dbconn);
>> ?>
>>
>> But I'm foiled by:
>>
>> Warning: pg_connect(): Unable to connect to PostgreSQL server:
>> could not connect
>> to server: Operation timed out Is the server running on host
>> "24.85.82.xxx" and
>> accepting TCP/IP connections on port 5432? in
>> /usr/local/psa/home/vhosts/weaktight.com/httpdocs/mytest.php on line 13
>>
>> Any thoughts or suggestions would be greatly appreciated. I'm not very
>> experienced with any of this stuff.
>>
>> Thanks.
>>
>>
>> ---------------------------(end of broadcast)---------------------------
>> TIP 2: Don't 'kill -9' the postmaster
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: 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
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-php@postgresql.org
Cc: vince@weaktight.com, gmr@ehpg.net
Subject: Re: PHP/postgreSQL
In-Reply-To: <20060204185415.f2fi0trmogg0880k@webmail.weaktight.com>
References: <20060204171435.7lfphylyooggs08c@webmail.weaktight.com> <1FC4E0E4-F55C-4308-8493-5680FEBD797E@ehpg.net> <20060204185415.f2fi0trmogg0880k@webmail.weaktight.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox