Setting DATABASE_URL for my MySQL DB fails for a Django App


#1

Hi there,

I’m new to Aptible, so forgive me if this is a silly question. I’m trying to deploy a very simple Django App with a MySQL DB as backend to the Aptible development environment.

In my settings.py file I’ve set this:

DATABASES = {
  'default': dj_database_url.config()
}

And then as a variable to my app, I’ve set the DATABASE_URL returned from creating the DB, with something like this

aptible config:set --app "app-dev" "DATABASE_URL=mysql://aptible:foo_bar@db-shared-us-east-1-doit-11338.aptible.in:24969/db"

… with the copy/pated URL from the DB credentials (I’ve replaced the password with foo_bar only for the purposes of this question).

When I try to deploy, I get this error message:

remote: INFO -- : django.db.utils.OperationalError: (1045, "Access denied for user 'aptible'@'ip-10-51-7-101.ec2.internal' (using password: YES)")
remote: ERROR -- : Prerelease commands failed: Non-zero exit code from command: 1.

Any thoughts on why this might be happening? The docs seem to suggest that this should work out of the box.

Thanks!
Octavian.


#2

I’m going to answer my own question in case this happens to somebody else in the future.

I filed a support ticket and Frank was really helpful in his response.

The solution was to force Django to use SSL.

In config.py I had to add this:

aptibleConfig = dj_database_url.config() 
aptibleConfig['OPTIONS'] = { 
  'ssl': { 
    'cipher': 'DHE-RSA-AES256-SHA' 
  } 
}

DATABASES = { 'default': aptibleConfig } 

That fixed it! Thanks Aptible!