title: django.db.utils.OperationalError: (2026, 'SSL connection error: SSL_CTX_set_tmp_dh failed') while connecting to localhost MYSQL
body: <p>I am trying to connect to Mysql server on localhost from my django application on Ubuntu 19.04.
  <strong>The database connection section in settings.py looks like this:</strong></p>
  
  <pre><code>DATABASES = {
      'default': {
          'ENGINE': 'django.db.backends.mysql',
          'NAME': 'app_datastore',
          'HOST' : '127.0.0.1',
          'USER': 'root',
          'PASSWORD': 'xxxx',
          'OPTIONS': {
                  'ssl': {
                      'ca': '/var/lib/mysql/ca.pem',
                      'cert': '/var/lib/mysql/client-cert.pem',
                      'key': '/var/lib/mysql/client-key.pem'
  
                      }
              }
      }
  }
  </code></pre>
  
  <p>It gives the error : </p>
  
  <blockquote>
    <p>django.db.utils.OperationalError: (2026, 'SSL connection error:
    SSL_CTX_set_tmp_dh failed')</p>
  </blockquote>
  
  <p>I can however connect to my mysql from both terminal and Dbeaver. mysql server is up.</p>
  
  <p><strong>Stackoverflow threads which I have already tried and doesnt work :</strong> </p>
  
  <p><a href="https://stackoverflow.com/questions/53385113/django-db-utils-operationalerror-2026-ssl-connection-error-ssl-ctx-set-tmp">django.db.utils.OperationalError: (2026, &#39;SSL connection error: SSL_CTX_set_tmp_dh failed&#39;)</a></p>
  
  <p><a href="https://stackoverflow.com/questions/54485148/ssl-connection-error-while-using-mysql-connector-with-python/54493292">SSL Connection Error while using MySQL Connector with Python</a></p>
  
  <p><a href="https://stackoverflow.com/questions/53819554/python-sql-connection-error-2006-ssl-connection-error-ssl-ctx-set-tmp-dh-fai">Python SQL connection error (2006, &#39;SSL connection error: SSL_CTX_set_tmp_dh failed&#39;)</a></p>
  
  <p>Here are my pip list results :</p>
  
  <p>Package      Version</p>
  
  <hr>
  
  <p>cffi         1.14.0 
  cryptography 2.8<br>
  Django       2.2.2<br>
  mysqlclient  1.4.6<br>
  Pillow       7.0.0<br>
  pip          20.0.2 
  pycparser    2.19<br>
  pyOpenSSL    19.0.0 
  pytz         2019.3 
  setuptools   45.2.0 
  six          1.14.0 
  sqlparse     0.3.0<br>
  wheel        0.34.2 </p>