cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

can't connect to remote database from PHP script at GoDaddy

I am trying to connect to a mySQL database at Azure with a PHP script at GoDaddy.  The GoDaddy IP is whitelisted -- but the attempt is not reaching their server (confirmed by Azure tech support).  Do I need to open a port and if so, how do I do that?

 

$azure_host = "recomlink.mysql.database.azure.com";
$azure_user   = "recomLink@recomlink";
$azure_pasw   = "[password]";
$azure_db     = "recommerce_dashboard";


$azure = mysqli_init();
mysqli_ssl_set($azure, NULL, NULL, '/home/[directory]/ssl/certs/BaltimoreCyberTrustRoot.crt.pem', NULL, NULL);
mysqli_real_connect($azure, $azure_host, $azure_user, $azure_pasw, $azure_db, 3306, MYSQLI_CLIENT_SSL, 64);
if (mysqli_connect_errno($azure)) {
    die('Failed to connect to MySQL: '.mysqli_connect_error());
}

Which returns:

Can't connect to MySQL server on 'recomlink.mysql.database.azure.com' (113)

 

This error seems to be complaining that there is no route to the host.

 

Help?

6 REPLIES 6
Community Manager
Community Manager

Re: can't connect to remote database from PHP script at GoDaddy

Hi @script_tease. Thanks for being part of GoDaddy Community! I'm not sure why that would be happening. As far as I know, there shouldn't be anything preventing you from connecting to the database with Azure. There is a very small possibility that the server you're trying to connect to is blocked on our end. That could happen if there were too many connection requests from the database, but that is unlikely. If you want to have that checked out, I'd suggest connecting with our hosting support team.

 

The fact that they're not seeing any requests from our end makes me suspect that either the script itself isn't working as intended or perhaps they have the wrong IP. You can double check the IP in your cPanel dashboard. As for ports, the receiving port with Azure would be the only one concerned, at least for fetching data. If the database itself is trying to connect to your server over a specific port, that could be a problem. You'd want to make sure it uses port 80 (or 443 if you're using HTTPS). No other ports would be open. If you're on a shared hosting cPanel plan, you would not be able to open other ports.

 

Hope this helps. 

 

JesseW - GoDaddy | Community Manager | 24/7 support available at x.co/247support | Remember to choose a solution and give kudos.

Re: can't connect to remote database from PHP script at GoDaddy

Hey Jesse,

 

Definitely on a shared cPanel hosting account and mySQL runs on port 3306 so I think we've hit upon the problem.  Is there an upgraded hosting account that makes this possible?  Please let me know our options?

 

Thanks sincerely,

Lauren

Community Manager
Community Manager

Re: can't connect to remote database from PHP script at GoDaddy

H1 @script_tease. 3306 would be open as well. However,  if you want your database to have remote access, you will need to enable remote MySQL by entering the IP of the server that is connecting. For more information, take a look here

 

JesseW - GoDaddy | Community Manager | 24/7 support available at x.co/247support | Remember to choose a solution and give kudos.

Re: can't connect to remote database from PHP script at GoDaddy

Hey Jesse,

 

Thanks for your response but I think we have lost track of the narrative.  I am *not* having trouble connecting to a MySQL database at GoDaddy. For that purpose I have remote SQL enabled and the IPs I need whitelisted.

 

I *am* having trouble connecting to a MySQL database NOT at GoDaddy *from* a PHP script at GoDaddy.

 

Any thoughts there?

Lauren

Community Manager
Community Manager

Re: can't connect to remote database from PHP script at GoDaddy

@script_tease. Only what I mentioned in my first reply. I was able to confirm (using test account) that under normal circumstances, a cPanel hosting plan can connect to an Azure database. The fact that Azure is apparently not seeing any connection is what is strange. If you're certain that the information you're using to connect to the remote database is correct, then I would suggest connecting with our hosting support team to rule out any kind of specific IP block. Sorry I can't be of more help. 

 

JesseW - GoDaddy | Community Manager | 24/7 support available at x.co/247support | Remember to choose a solution and give kudos.

Re: can't connect to remote database from PHP script at GoDaddy

Hey Jesse,

 

Thanks so much for your thoughts!  Much appreciated.

 

Lauren