New Coder
New Coder

Reputation: 155

Using mysql-connector-python in a flask app with uwsgi and receive the following error: SSL connection error: SSL_CTX_new failed

I have a flask app that makes use of a mysql connection that I have successfully run in development mode. To scale the app, I am intending to use a combination of Nginx and uwsgi.

Having setup the wsgi.py file and run the command:

uwsgi --socket 0.0.0.0:5000 --protocol=http -w wsgi:app

I receive the following error message after entering a url (that previously worked under development mode ie flask on its own without uwsgi):

mysql.connector.errors.InterfaceError: 2026 (HY000): SSL connection error: SSL_CTX_new failed

I have tried the solution suggested here: https://forums.mysql.com/read.php?50,671354,671376#msg-671376 however it did not work.

What should I do to solve this error?

Upvotes: 1

Views: 530

Answers (1)

TheHeuman
TheHeuman

Reputation: 178

I have found a solution that works for me.

https://stackoverflow.com/a/56497954/9137086

Adding

use_pure=True

to the end of the database connection string

so mine became

connection_string = f'{dialect}+{driver}://{user}:{password}@{host}:{port}/{database}?use_pure=True'

Upvotes: 1

Related Questions