Re: php connection failure

From: rob stone <floriparob(at)gmail(dot)com>
To: ourdiaspora <ourdiaspora(at)protonmail(dot)com>, Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: "pgsql-general(at)lists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: php connection failure
Date: 2021-08-11 13:10:40
Message-ID: a3cfdab09af1012591a269028c77725606a4fe3f.camel@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello,

On Wed, 2021-08-11 at 11:09 +0000, ourdiaspora wrote:
>
>
> The connection to postgresql seems OK now (thank you), but the php
> web page continues to fail to connect to the database:
>
> "
> <html>
>         <head>
>                 Generic CPAC database
>         </head>
>         <body>
>                 <?php
>                         $dbconn = pg_connect("dbname=cpacweb
> user=cpaca host=localhost") or die("Could not connect");
>                         $stat = pg_connection_status($dbconn);
>      if ($stat === PGSQL_CONNECTION_OK) {
>          echo 'Connection status ok';
>      } else {
>          echo 'Connection status bad';
>      }
>                 ?>
>         </body>
> </html>
> "
> Returns:
>
> "
> Generic CPAC database Could not connect
> "
>

I don't know which version of PHP you are running, but can you re-write
the call to pg_connect as a try . . . catch block so that the exact
error message is returned instead of just a "die"?

Are you sure postgres is configured to use port 5432? There is no
PGPORT environment variable set?

Why are you starting postgres with a -c option and no parameters
following?

I assume you know that version 9.6 of postgres is nearly at EoL.

HTH,
Rob

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message hubert depesz lubaczewski 2021-08-11 13:12:47 Getting pg_stat_database data takes significant time
Previous Message Daniel Verite 2021-08-11 11:24:57 Re: JWT decoder