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 |
Thread: | |
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
From | Date | Subject | |
---|---|---|---|
Next Message | tommaso.gastaldi | 2006-07-04 14:31:04 | OLEDB connection does not want to work. Help!! |
Previous Message | Franz.Rasper | 2006-07-04 07:40:11 | Re: RAID + PostgreSQL? |