Can you test:

#python2.6
>import psycopg2
>psycopg2.connect(database="prac2", user="postgres", password="password", 
>host="localhost")

Maybe the server is down, you have a firewall issue or your
pg_hba.conf is not open for localhost connections:
host    all             all             127.0.0.1 md5
hostssl    all             all             127.0.0.1               md5

(use 127.0.0.1 as ipv6 localhost address may conflict)

Best regards,

Mariano Reingart
http://www.sistemasagiles.com.ar
http://reingart.blogspot.com



On Sun, Sep 25, 2011 at 4:06 PM, lucas <sjluk...@gmail.com> wrote:
> hello one and all,
>
> i am having difficultly connecting postgres 9.1 under web2py v1.98.2
> on a centos 6.0 box which has python 2.6.5.  i have psycopg2 2.4
> installed and working in python when i run the test
>
> #python2.6 web2py -S welcom -N -a 'password'
> then
>>import psycopg2
>>
>
> works just fine.  however, when i put
>
> db = DAL('postgres://postgres:passwd@localhost:5432/prac2')
>
> and attempt to click on database administrator, i get for the
> traceback
>
> Traceback (most recent call last):
>  File "/opt/web-apps/web2py/gluon/restricted.py", line 192, in
> restricted
>    exec ccode in environment
>  File "/opt/web-apps/web2py/applications/prac2_with_postgresql/models/
> db.py", line 83, in <module>
>    db = DAL('postgres://root:@localhost:5432/prac2')
>  File "/opt/web-apps/web2py/gluon/dal.py", line 3981, in __init__
>    raise RuntimeError, "Failure to connect, tried %d times:\n%s" %
> (attempts, error)
> RuntimeError: Failure to connect, tried 5 times:
> could not connect to server: Permission denied
>    Is the server running on host "localhost" (127.0.0.1) and
> accepting
>    TCP/IP connections on port 5432?
>
> any ideas on what i have not done properly???  thank you in advance
> and have a great day.  lucas

Reply via email to