Forums

Can't connect to MySQL from outside Pythonanywhere

I've been having issues connecting to MySQL database from my local machine. I followed the guides for connecting from outside Pythonanywhere. I am able to SSH using PUTTY, Manual on CMD, and start a Pycharm shh session but I keep getting following error:
django.db.utils.OperationalError: (2002, "Can't connect to MySQL server on 'myusername.mysql.pythonanywhere-services.com' (10060)")
<br> I confirmed that the password matches the one in my .my.cnf file. I've tried changing passwords and dropping and creating a new database to connect to. <br><br> My Django connection looks as follows: <br><br>

   'default': {
        'ENGINE': "django.db.backends.mysql",
        'NAME': "myusername$qoder-production",
        'USER': "myusername",
        'PASSWORD': "myspecialpassword",
        'HOST': "myusername.mysql.pythonanywhere-services.com",
        'OPTIONS': {
            'init_command': "SET sql_mode='STRICT_TRANS_TABLES'",
        },
    }

I changed hostname from myusername.mysql.pythonanywhere-services.com to 127.0.0.1 and it now connects. Can't believe I was stuck on this for over 24hrs. Can someone explain what's happening since this isn't exactly my field of expertise. Would love to learn to know for future. Also, do I need to change it back to myusername.mysql.pythonanywhere-services.com when running on the server instead of on my machine?

Looks like we already talk over support email. Let's continue there.