Didn't you say? db = DAL('postgres://web2py:12...@127.0.0.1:1216/labdb', pool_size=10)
is the DB at port 1216 or 5432? Can you try with pool_size=0 just to isolate the problem. On Aug 7, 6:42 pm, Zhe Li <linuxcity...@gmail.com> wrote: > Hi Massimo, > > I am using PostgreSQL 8.4. > > I added print(msg) and got the message when runnning python web2.py -a > 123, the string looks like > > dbname='labdb' user='web2py' host='localhost' port=5432 > password='test123' > > I only have this error when using web2py with WSGI. But if I go to the > shell from the admin page running with WSGI, I could use PostgreSQL > without any problems. I tried this: > > conn = psycopg2.connect("dbname='labdb' user='web2py' host='localhost' > port=5432 password='test123'") > > and it works, I successfully added a table and a test record... > > Thank you! > > Cheers, > Zhe > > On Aug 7, 5:30 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > One more test: > > > In gluon/sql.py > > > before line 957, print your connection string: > > print msg > > Would that connection string work on the shell? Which postgresql > > version are you using? > > > On Aug 6, 6:48 am, Zhe Li <linuxcity...@gmail.com> wrote: > > > > Yeah, that works fine. It's so odd and frustrating... > > > > On Aug 6, 1:25 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > I have no idea. Can you connect from a pure python shell using the > > > > driver API? > > > > > On Aug 6, 5:55 am, Zhe Li <linuxcity...@gmail.com> wrote: > > > > > > thanks! > > > > > I tried to replace localhost with 127.0.0.1, 192.168.0.16 (it's > > > > > actually ip). but it doesn't work.... > > > > > > Cheers, > > > > > Zhe > > > > > > On Aug 6, 12:33 pm, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > > Try replace > > > > > > > localhost > > > > > > with > > > > > > 127.0.0.1 > > > > > > and with the actual IP of the machine. It may not be serving on > > > > > > localhost > > > > > > > On Aug 6, 5:25 am, Zhe Li <linuxcity...@gmail.com> wrote: > > > > > > > > Hi, > > > > > > > > Thanks! This is the result from trunk. > > > > > > > > Error traceback > > > > > > > Traceback (most recent call last): > > > > > > > File "gluon/restricted.py", line 186, in restricted > > > > > > > exec ccode in environment > > > > > > > File "/home/www-data/web2py/applications/welcome/models/db.py", > > > > > > > line > > > > > > > 15, in <module> > > > > > > > db = DAL('postgres://web2py:test...@localhost:1216/labdb') > > > > > > > # > > > > > > > if not, use SQLite or other DB > > > > > > > File "gluon/sql.py", line 3911, in DAL > > > > > > > raise RuntimeError, "%s (tried 5 times)" % exception > > > > > > > RuntimeError: could not connect to server: Connection refused > > > > > > > Is the server running on host "localhost" and accepting > > > > > > > TCP/IP connections on port 1216? > > > > > > > could not connect to server: Connection refused > > > > > > > Is the server running on host "localhost" and accepting > > > > > > > TCP/IP connections on port 1216? > > > > > > > (tried 5 times) > > > > > > > Error snapshot > > > > > > > Detailed traceback description > > > > > > > Exception: <type 'exceptions.RuntimeError'>(could not connect to > > > > > > > server: Connection refused Is the server running on host > > > > > > > "localhost" > > > > > > > and accepting TCP/IP connections on port 1216? could not connect > > > > > > > to > > > > > > > server: Connection refused Is the server running on host > > > > > > > "localhost" > > > > > > > and accepting TCP/IP connections on port 1216? (tried 5 times)) > > > > > > > Python 2.6.5: /usr/bin/python > > > > > > > > This is odd since I can connect to it both from command-line and > > > > > > > another machine using web2py account.... > > > > > > > > Cheers, > > > > > > > Zhe > > > > > > > > On Aug 6, 11:06 am, mdipierro <mdipie...@cs.depaul.edu> wrote: > > > > > > > > > Please check the version in trunk. It should give you a more > > > > > > > > detailed > > > > > > > > error. > > > > > > > > > On Aug 6, 3:06 am, Zhe Li <linuxcity...@gmail.com> wrote: > > > > > > > > > > Hello everyone, > > > > > > > > > > I tried to deploy web2py on my ubuntu server using > > > > > > > > > setup_web2py_ubuntu.sh. Everything seemed fine except when I > > > > > > > > > switch > > > > > > > > > database from SQLite to PostgreSQL I got: > > > > > > > > > > Error traceback > > > > > > > > > Traceback (most recent call last): > > > > > > > > > File "gluon/restricted.py", line 178, in restricted > > > > > > > > > exec ccode in environment > > > > > > > > > File > > > > > > > > > "/home/www-data/web2py/applications/init/models/db.py", line > > > > > > > > > 16, in <module> > > > > > > > > > db = DAL('postgres://web2py:12...@127.0.0.1:1216/labdb', > > > > > > > > > pool_size=10) > > > > > > > > > File "gluon/sql.py", line 3911, in DAL > > > > > > > > > raise RuntimeError, "Failure to connect to DB. Tried 5 > > > > > > > > > times" > > > > > > > > > RuntimeError: Failure to connect to DB. Tried 5 times > > > > > > > > > > but if I run the web server using: > > > > > > > > > > python web2.py > > > > > > > > > > it works fine. I got the same issue with MySQL as well. > > > > > > > > > > Could you tell me what the problem might be? Thanks! > > > > > > > > > > Cheers, > > > > > > > > > Zhe