How to connect Django app to digital ocean managed database (MySQL) ?

Posted December 19, 2019 3.8k views

I am kind of a beginner so I can be doing something very wrong, but this is my situation:
I was trying to connect my Django application to my Digital ocean’s MySQL database, with the following configurations:


    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': '<name>',
        'USER': 'doadmin',
        'PASSWORD': '<pass>',
        'HOST': '<host>',
        'PORT': '25060',
        'OPTIONS': {
            'ssl': {
                'ca': <ca_certificate_downloaded_from_managing_page>,
                'cert': None,
                'key': None,

These specifications were copied from the digital ocean cluster managing webpage, so no typos.
I’ve downloaded the CA certificate and provided everything that was asked. With DBeaver everything seems to work fine. I’ve also tried to update mysql client but nothing works.
This is the error that pops on the console:

  File "C:\Users\Alexandre\AppData\Local\Programs\Python\Python38-32\lib\site-packages\MySQLdb\", line 179, in __init__
    super(Connection, self).__init__(*args, **kwargs2)
django.db.utils.OperationalError: (2026, 'SSL connection error: unknown error number')

I’ve ran out of ideas.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


I just created a new Django project using python 3 and configured the Database backend the same way yo did except for the SSL options, I left them to use defaults and it worked without any issues.

Please could you try again using my configuration? Python 3 and no SSL options.

Hope this helps