(0 comments)

Lately I have spotted that some of the connection request between my Django app and remote Postgres DB are randomly failing.

OperationalError: could not connect to server: Connection refused
    Is the server running on host "xxxxx" (xx.xx.xx.xx) and accepting
    TCP/IP connections on port 5432?

Since I have a very limited access to the database host, I came across with a solution, which is creation of a persistent connections:

There is in fact an implementation of reusing SQLAlchemy's connection 
pool with Django (via DatabaseWrapper subclassing):
https://github.com/kennethreitz/django-postgrespool/

So far worksforme. :-)

BTW: Please note that django-postgrespool by default will not work with Django 1.6 due to this patch:

https://github.com/django/django/commit/59a352087591a26023412cbcb830cd1d34fc9b99 
https://github.com/kennethreitz/django-postgrespool/issues/18#issuecomment-35962151

What you can do is to try to revert it or go for >1.6 or <1.6.

Currently unrated

Comments

There are currently no comments

New Comment

required

required (not published)

optional