Menggunakan param socketPath saat menghubungkan ke mysql membantu.
var connection = mysql.createConnection({
host : 'ip_address',
user : 'root',
password : 'password',
database : 'database_name'
socketPath: “/cloudsql/projectName:zone:instance-name”
});