Question
Php/mySQL connection to remote server, fatal error, connection timeout
I’ve got one droplet at DO and one webspace with domain at another hosting provider. I don’t have access to anything other than ftp on the other server. On that other webspace I’ve got a php script which I want to remotely connect to my mySQL db on my droplet. I’ve opened the port 3306 in the firewall, added a user with access to the table from % and changed the row starting with “bind-adress” (also tried commenting out) in the configuration file. Still I get an error like this when trying to connect:
Fatal error: Uncaught exception ‘PDOException’ with message 'SQLSTATE[HY000] [2002] Connection timed out’ in {the url to the script that’s trying to connect}:19 Stack trace: #0 {the url to the script that’s trying to connect}(19): PDO->__construct('mysql:host={my droplet public ip}, ’{username}’, ’{password}’) #1 {main} thrown in {the url to the script that’s trying to connect} on line 19
And the connection part in php looks like this:
$db = new PDO('mysql:host={droplet public ip};port=3306;dbname={database name};charset=utf8’, ’{username}’, ’{password}’);
What am I doing wrong?!
I’ve contacted the DO support, they couldn’t help me since we don’t know where the problem is. They told me to try the community.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×
Unfortunately this is unsolvable. When I contacted the support of the web server hosting company again, they told me that neither incoming or outgoing requests to another database was allowed on their servers. Despite that they told me earlier this morning that outgoing requests was allowed.