Forums

cannot connect to mysql database from localhost

mysql.connector.errors.DatabaseError: 2003 (HY000): Can't connect to MySQL server on 'OutwordDestroyer.mysql.pythonanywhere-services.com:3306' (10060). I just bought a hacker account, restarted the applications and created a new console. Now I can't connect to the database from the local host.I have rechecked all the filled data a thousand times, if someone has a solution to the problem, please share.

enter image description here

cannot connect to mysql database from localhost

The code you posted would close the SSH tunnel to the database connection at the end of the with block in the function __enter__ -- any code that talks to the database needs to be inside that with block.