I have a mysql Database which is hosting on a windows server under the domain: https://<some-domain>.net/phpmyadmin/index.php
and I’m trying to connect to this database in my flask app from outside the server but it cannot connect to server.
my python code:
conn = mysql.connector.connect(host='https://<some-domain>.net/phpmyadmin/index.php',
user='user',
password='password',
database='db',
port='3306')
I also tried with the IP-Address of the domain and it did not worked.
locally on Windows-Server it works without any problem, but when I try to reach the database from outside the Windows-Server, it would not connect.
With Domain as host I get an:
mysql.connector.errors.InterfaceError: 2003: Can’t connect to MySQL server on ‘%-.100s:%u’ (%s) (Warning: %u format: a real number is required, not str)
With IP-Address as host I get an:
mysql.connector.errors.InterfaceError: 2003: Can’t connect to MySQL server on ‘217.237.79.165: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)
Does anyone have a solution how to connect to the database from outside the windows Server?
2
Answers
Most likely you’re running into a firewall issue on your windows host or the network the windows host is on.
this tells me that the box that your flask app is sitting on can’t even communicate with the IP of your windows host. You will want to troubleshoot that.
run a
traceroute 217.237.79.165
ortracert 217.237.793.165
to see where the connection is dying.If your flask app is sitting on another windows box, you can use the powershell command:
to get an idea if you’re having issues at the port level as well.
good luck
port=3306
(default port of MySQL)For
mysql.connector.connect
method on Python:https://dev.mysql.com/doc/connector-python/en/connector-python-connectargs.html