Forums

[Errno 61] Connection refused

I build a simple app that pulls data from an API in json format. I parse the data and append to MySQL. I built everything utilizing @localhost. From my @localhost database I export a .sql file which I uploaded to pythonanywhare. I opened the MySQL console, USE user$db and source /home/user/file.sql. After all that I verify that the data was indeed uploaded by doing some queries. Now I'm trying to append to the database by running the script locally in my laptop but I'm getting a Connection refused error. Here is the code that connects to the database...

engine = create_engine('mysql+pymysql://user$database:password@user.mysql.pythonanywhere-services.com')

I'm thinking that has something to do with credentials and the way I'm building the engine.

I build a simple app that pulls data from an API in json format. I parse the data and append to MySQL. I built everything utilizing @localhost. From my @localhost database I export a .sql file which I uploaded to pythonanywhare. I opened the MySQL console, USE user$db and source /home/user/file.sql. After all that I verify that the data was indeed uploaded by doing some queries. Now I'm trying to append to the database by running the script locally in my laptop but I'm getting a Connection refused error. Here is the code that connects to the database...

engine = create_engine('mysql+pymysql://user$database:password@user.mysql.pythonanywhere-services.com')

I'm thinking that has something to do with credentials and the way I'm building the engine.

Yup. It is good practice to block access to the databases over the internet because of security concerns. Instead, you will have to use ssh-tunnelling (but ssh is only available for paying users).