Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App engine fails to connect to Google cloud sql

Tags:

People also ask

How do I connect Google Cloud to SQL?

In the Google Cloud console, go to the Cloud SQL Instances page. To open the Overview page of an instance, click the instance name. Select Connections from the SQL navigation menu. In the Authorized networks section, click Add network and enter the IP address of the machine where the client is installed.

Is Google App Engine and Google Cloud same?

Basic difference is that Google App Engine (GAE) is a Platform as a Service (PaaS) whereas Google Compute Engine (GCE) is an Infrastructure as a Service (IaaS). To run your application in GAE you just need to write your code and deploy it into GAE, no other headache.


My Google app engine application fails to connect to Google cloud sql instance with this error:

'PDOException' with message 'SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it.

I've checked the documentation and followed instructions closely. I added the app as an authorised application and set the root password using the cloud console. I also gave the instace an ip address and can connect to it from Workbench on the local development machine. Using workbench, I added a user and configured permissions. But I'm still unable to connect to it from the dev version of the app (same ip as workbench) or the deployed app.

Here's my connection line:

$conn = new PDO('mysql:unix_socket=/cloudsql/****:****;charset=utf8', 'the_username', 'its_password');

this question appears to be similar to this problem. However, even after setting up a new user and granting permissions I'm still unable to connect. Any idea where I went wrong?

Thanks