0

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.

AJW
  • 5,569
  • 10
  • 44
  • 57

1 Answers1

0

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

Kevin Joymungol
  • 1,764
  • 4
  • 20
  • 30
  • Could you please explain what you mean by `May be your django application's connection string is still using postgresql username and password.`? I am using the same username, password for both the django sites - It is just the database name which is different - is this not how it is supposed to be? Sorry if the question is 101. – AJW Feb 13 '14 at 17:04
  • I have never used django but I think that instead of USERNAME postgres and PASSWORD SECRET_KEY, you should use the pgbouncer username.and password. This is found in the pgbouncer config file, auth_type field. – Kevin Joymungol Feb 13 '14 at 17:17