Forums

Connection to MySQL server

A couple of times now (most recently 22.4.24) my error log has shown an error connecting to MySQL server (extract from error log below). This is on a Django site which is otherwise working fine and is in regular use. The settings have not been changed in ages. Any idea what will have caused the error? I'd ideally like to avoid any repetition but maybe this kind of occasional hiccup is unavoidable.

django.db.utils.OperationalError: (2003, "Can't connect to MySQL server on '*.mysql.eu.pythonanywhere-services.com:3306' (113)")

Is the "*" in that error message something that you added yourself to hide the database name? If not, it looks a bit odd.

Yes, it was a slightly clumsy and probably pointless redaction of the host address. I stress that my site generally works fine and the settings have not changed in ages, so I can't see how there could be any problem with the settings. My guess is that there was a very short-lived problem with the database server - is that a possibility?

Here is another extract from the error log, without any editing: MySQLdb._exceptions.OperationalError: (2003, "Can't connect to MySQL server on 'PupillageProduction.mysql.eu.pythonanywhere-services.com:3306' (113)")

Could you check if your DATABASES setup match the instructions here?

Yes, it matches that setup. Django settings as per that page (with one option also set). It all works fine 99.9% of the time.

Right, if it fails only sometimes, it may be related to the server business, we'll have a look.