Lists: | pgsql-general |
---|
From: | "Clodoaldo Pinto" <clodoaldo(dot)pinto(at)gmail(dot)com> |
---|---|
To: | "pgsql-general postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | php can't connect to postgresql server |
Date: | 2006-07-03 13:25:29 |
Message-ID: | a595de7a0607030625o63876d74n35bad5236de6c0fe@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
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 "127.0.0.1" 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
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.
Regards, Clodoaldo Pinto
From: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: php can't connect to postgresql server |
Date: | 2006-07-03 13:39:19 |
Message-ID: | 20060703133919.GC4905@webserv.wug-glas.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
am 03.07.2006, um 10:25:29 -0300 mailte Clodoaldo Pinto folgendes:
> $conn_string = "hostaddr=127.0.0.1 port=5432 dbname=dbname
^^^^^^^^^
> I can connect as that user with psql:
>
> $ psql -h localhost -U username dbname
^^^^^^^^^
Try 'localhost' instead '127.0.0.1' in your $conn_string.
My guess: pg don't listen on tcp/ip, only on the local socket.
(check listen_addresses in your postgresql.conf)
HTH, Andreas
--
Andreas Kretschmer (Kontakt: siehe Header)
Heynitz: 035242/47215, D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
=== Schollglas Unternehmensgruppe ===
From: | "Clodoaldo Pinto" <clodoaldo(dot)pinto(at)gmail(dot)com> |
---|---|
To: | "A(dot) Kretschmer" <andreas(dot)kretschmer(at)schollglas(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: php can't connect to postgresql server |
Date: | 2006-07-03 13:51:05 |
Message-ID: | a595de7a0607030651v1b802189sdd44901bf3a65041@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
2006/7/3, A. Kretschmer <andreas(dot)kretschmer(at)schollglas(dot)com>:
> am 03.07.2006, um 10:25:29 -0300 mailte Clodoaldo Pinto folgendes:
> > $conn_string = "hostaddr=127.0.0.1 port=5432 dbname=dbname
> ^^^^^^^^^
>
> > I can connect as that user with psql:
> >
> > $ psql -h localhost -U username dbname
> ^^^^^^^^^
>
> Try 'localhost' instead '127.0.0.1' in your $conn_string.
As I already said I have tried localhost also.
> My guess: pg don't listen on tcp/ip, only on the local socket.
> (check listen_addresses in your postgresql.conf)
listen_addresses = '127.0.0.1,xx.xx.xxx.xx'
If I can connect with the -h localhost psql's option then I guess it
is listening to tcp/ip, isn't it?
Clodoaldo
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 |
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 "127.0.0.1" 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)
From: | "Clodoaldo Pinto" <clodoaldo(dot)pinto(at)gmail(dot)com> |
---|---|
To: | "Robert Treat" <xzilla(at)users(dot)sourceforge(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: php can't connect to postgresql server |
Date: | 2006-07-03 14:29:42 |
Message-ID: | a595de7a0607030729s65d9c6a0gf340b197f3934e43@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
2006/7/3, Robert Treat <xzilla(at)users(dot)sourceforge(dot)net>:
> 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 "127.0.0.1" 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.
Changed to host=localhost as I had already done before with the same
results. From the php manual:
"The currently recognized parameter keywords are: host, hostaddr,..."
> > What else should I check? I am out of ideas.
> >
>
> Make sure that your postgresql.conf "listen_addresses" is properly set,
What do you mean by properly set? What I had already post is not properly set?:
listen_addresses = '127.0.0.1,xx.xx.xxx.xx'
> make sure you dont have a firewall setting that is blocking connections, the
> default firewall settings on FC boxes are notorious for blocking pg.
Opened the 5432 port in the firewall and still the same problem.
Clodoaldo
From: | "Clodoaldo Pinto" <clodoaldo(dot)pinto(at)gmail(dot)com> |
---|---|
To: | "pgsql-general postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: php can't connect to postgresql server |
Date: | 2006-07-03 15:13:01 |
Message-ID: | a595de7a0607030813s11391606t757ef3fe114b5731@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
2006/7/3, Clodoaldo Pinto <clodoaldo(dot)pinto(at)gmail(dot)com>:
> 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 "127.0.0.1" 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
>
> 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.
The same script running from another server can connect to the new
server using this pg_hba entry:
host dbname usename xx.xx.xxx.xx/32 md5
Clodoaldo
From: | "Alejandro Michelin Salomon \( Adinet \)" <alejmsg(at)adinet(dot)com(dot)uy> |
---|---|
To: | "'Clodoaldo Pinto'" <clodoaldo(dot)pinto(at)gmail(dot)com> |
Cc: | "Pgsql-General" <pgsql-general(at)postgresql(dot)org> |
Subject: | RES: php can't connect to postgresql server |
Date: | 2006-07-03 22:04:28 |
Message-ID: | !~!UENERkVCMDkAAQACAAAAAAAAAAAAAAAAABgAAAAAAAAAhx491Ki2tUS42D/aMPFg1MKAAAAQAAAAgi3j2pHQ9EC0ko4x9cAHzQEAAAAA@adinet.com.uy |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
Clodoaldo Pinto worte:
-->-----Mensagem original-----
-->De: pgsql-general-owner(at)postgresql(dot)org
-->[mailto:pgsql-general-owner(at)postgresql(dot)org] Em nome de
-->Clodoaldo Pinto
-->Enviada em: segunda-feira, 3 de julho de 2006 12:13
-->Para: pgsql-general postgresql.org
-->Assunto: Re: [GENERAL] php can't connect to postgresql server
-->
-->
-->2006/7/3, Clodoaldo Pinto <clodoaldo(dot)pinto(at)gmail(dot)com>:
-->> 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 "127.0.0.1" 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
-->>
-->> 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.
-->
-->The same script running from another server can connect to
-->the new server using this pg_hba entry:
-->host dbname usename xx.xx.xxx.xx/32 md5
-->
-->Clodoaldo
postgresql.conf -->
listen_addresses = '*' ---- >This is any ip.
pg_hba.conf -->
# TYPE DATABASE USER CIDR-ADDRESS METHOD
# IPv4 local connections:
host all all 127.0.0.1/32 md5
This is the configuration that i choose when install postgresql in windows
xp.
Try this.
Alejandro Michelin Salomon
Porto Alegre
Brasil
From: | "Clodoaldo Pinto" <clodoaldo(dot)pinto(at)gmail(dot)com> |
---|---|
To: | "pgsql-general postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: php can't connect to postgresql server |
Date: | 2006-07-04 13:11:31 |
Message-ID: | a595de7a0607040611r3432185fs8487f1fddd3f4d9@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Lists: | pgsql-general |
2006/7/3, Clodoaldo Pinto <clodoaldo(dot)pinto(at)gmail(dot)com>:
> 2006/7/3, Clodoaldo Pinto <clodoaldo(dot)pinto(at)gmail(dot)com>:
> > 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 "127.0.0.1" 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
> >
> > 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.
>
> Solved. It was a SELinux problem. From /var/log/messages:
>
> kernel: audit(1151945653.900:39): avc: denied { name_connect } for
> pid=17167 comm="httpd" dest=5432 scontext=user_u:system_r:httpd_t:s0
> tcontext=system_u:object_r:postgresql_port_t:s0 tclass=tcp_socket
>
> Again followed this:
>
> http://fedora.redhat.com/docs/selinux-faq-fc5/#id2961385
>
> I searched for this problem and I wonder how could nobody reported it
> before. Am I the only one connecting locally to pgsql from php with
> SELinux enabled in a FC5 box or what?
A much simpler solution:
# setsebool -P httpd_can_network_connect_db 1
Regards, Clodoaldo Pinto