postgres connection problem via python pg DBI

Lists: pgsql-general
From: Colin Wetherbee <cww(at)denterprises(dot)org>
To: Dan Joo <djoo(at)agraquest(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: postgres connection problem via python pg DBI
Date: 2008-06-05 16:26:43
Message-ID: 484813C3.3060200@denterprises.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Dan Joo wrote:
> db=pg.connect('aqdev','localhost',5432,None,None,'postgres',None)
>
> From the commandline the connection works great, but from a
> cgi-script it barfs with the following message:
>
> *InternalError*: could not create socket: Permission denied

My (obvious, granted) guess is that you're running it from the command
line as your own user, but the web server is running under another user
who doesn't have the proper permissions (or ident response) to access
the database.

Colin


From: "Dan Joo" <djoo(at)agraquest(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: postgres connection problem via python pg DBI
Date: 2008-06-05 23:17:58
Message-ID: 4676DF8318F32F4AB7E98BCD9BC90628F3E153@agq-ex01.agraquest.int
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Hi all,

I have a problem connecting to postgres via the python pg module ONLY
from the cgi-scripts.

The command is:

db=pg.connect('aqdev','localhost',5432,None,None,'postgres',None)

From the commandline the connection works great, but from a cgi-script
it barfs with the following message:

InternalError: could not create socket: Permission denied

Does anyone have any idea how I can get around this issue?

Thanks a bunch!


From: "Dan Joo" <djoo(at)agraquest(dot)com>
To: "Dan Joo" <djoo(at)agraquest(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: postgres connection problem via python pg DBI
Date: 2008-06-05 23:34:11
Message-ID: 4676DF8318F32F4AB7E98BCD9BC90628F3E162@agq-ex01.agraquest.int
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-general

Just solved it.

For others, here is the solution.

setsebool -P httpd_can_network_connect_db 1

From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Dan Joo
Sent: Thursday, June 05, 2008 4:18 PM
To: pgsql-general(at)postgresql(dot)org
Subject: [GENERAL] postgres connection problem via python pg DBI

Hi all,

I have a problem connecting to postgres via the python pg module ONLY
from the cgi-scripts.

The command is:

db=pg.connect('aqdev','localhost',5432,None,None,'postgres',None)

From the commandline the connection works great, but from a cgi-script
it barfs with the following message:

InternalError: could not create socket: Permission denied

Does anyone have any idea how I can get around this issue?

Thanks a bunch!