Re: php can't connect to postgresql server

From: Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>
To: pgsql-general(at)postgresql(dot)org
Cc: "Clodoaldo Pinto" <clodoaldo(dot)pinto(at)gmail(dot)com>
Subject: Re: php can't connect to postgresql server
Date: 2006-07-03 14:01:57
Message-ID: 200607031001.57342.xzilla@users.sourceforge.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Monday 03 July 2006 09:25, Clodoaldo Pinto wrote:
> php can't connect to postgresql server
>
> php error log message:
>
> PHP Warning: pg_connect() [<a
> href='function.pg-connect'>function.pg-connect</a>]: Unable to connect
> to PostgreSQL server: could not connect to server: Permission
> denied\n\tIs the server running on host &quot;127.0.0.1&quot; and
> accepting\n\tTCP/IP connections on port 5432?
>
> php connection string:
>
> $conn_string = "hostaddr=127.0.0.1 port=5432 dbname=dbname
> user=username password=password";
>
> Also tried host=localhost
>

It needs to be host, not hostaddr.

> pg_hba:
>
> host dbname username 127.0.0.1/32 md5
>
> I can connect as that user with psql:
>
> $ psql -h localhost -U username dbname
> Password for user username:
> Welcome to psql 8.1.4, the PostgreSQL interactive terminal.
>
> This same setup works in another server running 8.0. Differences:
>
> old server | new server
> FC3 | FC5
> php 4.3.11 | php 5.1.4
> httpd 2.0 | httpd 2.2
>
> What else should I check? I am out of ideas.
>

Make sure that your postgresql.conf "listen_addresses" is properly set, also
make sure you dont have a firewall setting that is blocking connections, the
default firewall settings on FC boxes are notorious for blocking pg.

--
Robert Treat
Build A Brighter LAMP :: Beginning PHP and PostgreSQL 8 (ISBN 1590595475)

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-07-03 14:08:57 Re: How serious are these problems?
Previous Message Steven Ridgway 2006-07-03 13:57:03 How serious are these problems?