Question

I am trying to learn a bit of pgbouncer with postgres and django - but I seem to have a problem when under production.

So, I have a django site say site1, which uses the following django database settings.py:

SECRET_KEY = "dbpassword"
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2', 
        'NAME': 'site1db1',                      
        'USER': 'postgres',
        'PASSWORD': SECRET_KEY,
        'HOST': 'localhost',                     
        'PORT': '12517', # custom pgbouncer post                     
      }
   }

the above works all fine with site1 - and this is running live on production. Now, I introduce another django site (separate django installation) called site2 with a new database site2db2. So, at the moment, I have my settings.py for site2 in django as follows:

SECRET_KEY = "dbpassword"
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2', 
        'NAME': 'site2db2',                      
        'USER': 'postgres',
        'PASSWORD': SECRET_KEY,
        'HOST': 'localhost',                     
        'PORT': '12517', # custom pgbouncer post                     
      }
   }

unfortunately, when I try to syncdb this second django site, I get;

django.db.utils.OperationalError: ERROR:  Auth failed

I am assuming that this is because site1 is using the same port as site2? How does one get around this problem. Any guidance pointing me to the right direction would be great.

Was it helpful?

Solution

May be your django application's connection string is still using postgresql username and password. Set the connection string to the port number, username, and password of pgbouncer. Check auth_type in the config file of pbBouncer, set it to trust and see if it works.

Hope that this gives you a hint

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top