Forums

Cannot connect to MySQL via Django.

Hi,

Did some configuration in the bare-bone Django project and cannot connect to MySQL instance. MySqlClient is installed via pip. Account in PA is not a free one :) So it should be available from the outside.

django.db.utils.OperationalError: (2002, "Can't connect to server on 'username.mysql.eu.pythonanywhere-services.com' (10060)").

DB settings in Django:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'diademisteu$RTG_EBOOK',
        'USER': 'diademisteu',
        'PASSWORD': 'myPass',
        'HOST': 'diademisteu.mysql.eu.pythonanywhere-services.com',
    }
}

Any ideas what I am doing wrong? Or perhaps I am missing the idea here?

You will need to use an SSH tunnel to connect to an EU database from a US account: https://help.pythonanywhere.com/pages/AccessingMySQLFromOutsidePythonAnywhere/ Though that may be quite difficult with Django on PythonAnywhere, since there is nowhere that you can run the code to run the tunnel.