So, I have already created a new security group rds_access
for my RDS instance with Inbound-> >Source parameter set to 0.0.0.0/0
, and updated the instance so in the 'Security groups' section on RDS Dashboard I have: rds_access (sg-xxx)( active )
In MySQL Workbench "Edit" section of my connection, in the tab "Remote Manager" I have set the value of "Native Windows remote management" radio button to active and "Hostname" parameter to 0.0.0.0
.
The instance and the database connect successfully.
In my web-application running on pythonanywhere I'm still getting this error:
OperationalError: (2003, "Can't connect to MySQL server on 'bachelor-diploma-db.cx0stetemb8k.eu-central-1.rds.amazonaws.com' ([Errno 111] Connection refused))
Before uploading my app on pythonanywhere, I've tested it on localhost
and everything was working fine. Also I have rebooted both the RDS instance and MySQL database.
Please, tell me what am I doing wrong and how to fix this issue?
UPDATE:
In order to connect to MySQL server I use flask-mysql
. Here's the code snippet:
from flaskext.mysql import MySQL
api = Api(app)
mysql = MySQL()
app.config['MYSQL_DATABASE_USER'] = 'user'
app.config['MYSQL_DATABASE_PASSWORD'] = 'password'
app.config['MYSQL_DATABASE_DB'] = 'bachelor_diploma_db'
app.config['MYSQL_DATABASE_HOST'] = 'bachelor-diploma-db.cx0stetemb8k.eu-central-1.rds.amazonaws.com'
mysql.init_app(app)
and then in methods I use:
conn = mysql.connect()
Probably because you're on a free PythonAnywhere account and free accounts can only connect out on http(s) to a specific whitelist of sites.