Can't connect to Cloud SQL from Compute Engine

28 views
Skip to first unread message

Ram Gupta

unread,
Feb 10, 2020, 9:10:07 AM2/10/20
to Google Cloud SQL discuss
Hi,

I am receiving "ERROR 2003 (HY000): Can't connect to MySQL server on " on connecting to Cloud SQL from Compute Engine. Both are in the same project. I have added compute engine IP Address to the allowed connections.

Pierre-Yves (Google Cloud Support)

unread,
Feb 11, 2020, 8:18:55 AM2/11/20
to Google Cloud SQL discuss

Hello Ram,


According to MySQL documentation [1], this error is thrown when a network connection has been refused. If you are using a private IP, then make sure your Compute Engine instance is in the same region as the Cloud SQL instance and on the network configured for a private connection. You can follow these guidelines [2] for private IP connection, or these steps [3] for public IP. If you have enabled SSL on the instance, here is how to set this up for proper connections [4].


[1] https://dev.mysql.com/doc/refman/5.7/en/can-not-connect-to-server.html

[2] https://cloud.google.com/sql/docs/mysql/connect-compute-engine#connecting_using_private_ip 

[3] https://cloud.google.com/sql/docs/mysql/connect-compute-engine#gce-connect-ip 

[4] https://cloud.google.com/sql/docs/mysql/connect-admin-ip#connect-ssl

Sangram Rath

unread,
Feb 11, 2020, 8:27:37 AM2/11/20
to Google Cloud SQL discuss
Could you share the complete error, one that includes the user it is trying to connect as?
I normally use sudo before the "mysql ..... " command to resolve this error.
Reply all
Reply to author
Forward
0 new messages