Forums

Can't connect to MySQL server, host has failed to respond

.

 login = "mysql+mysqlconnector://{username}:{password}@{host}/{dbname}".format(
        username="VoxLight",
        password="PASSWORD",
        host="VoxLight.mysql.pythonanywhere-services.com",
        dbname="VoxLight$default"
    )
print(login)
app.config["SQLALCHEMY_DATABASE_URI"] = login

This is how I am setting up the SQLALCHEMY_DATABASE_URI. Whenever I use a SQLite local database, my app works as expected, so the issue lies somewhere between defining the MySQL URI and the remote database.

I just recently upgraded so that I could make remote requests to the mysql server. Could it just be that it hasn't been long enough for the firewall to be unblocked? Everything seems correct. I have spent about an hour trying to find a solution, and I have scoured many forum posts and stackoverflow, and I am continuously greeted with the same error message whenever I try to start my app:

sqlalchemy.exc.InterfaceError: (mysql.connector.errors.InterfaceError) 2003: Can't connect to MySQL server on 'VoxLight.mysql.pythonanywhere-services.com:3306' (10060 A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond)

(Background on this error at: https://sqlalche.me/e/20/rvf5)

This is what the URI looks like when the request is made, only I have replaced the mysql db password with PASSWORD to protect that information.

mysql+mysqlconnector://VoxLight:PASSWORD@VoxLight.mysql.pythonanywhere-services.com/VoxLight$default

Any help on this, or confirmation of my suspicion of me needing to wait for the firewall would be helpful.

[edit by admin: formatting]

Are you trying to connect to the MySQL server from code that is not running inside PythonAnywhere? If so, there are further steps that you'll need to take, as you'll need to use an SSH tunnel to connect to it. This help page has the details.

Darn, I was hoping that was not the case. Thank you for the reply.