Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud SQL + Heroku

Here is error message that I got!

2014-03-13T08:30:21.010764+00:00 heroku[web.1]: Starting process with command `node dbserver.js`
2014-03-13T08:30:22.485293+00:00 app[web.1]: listening on 14218
2014-03-13T08:30:22.486771+00:00 app[web.1]: lo 127.0.0.1
2014-03-13T08:30:22.551389+00:00 app[web.1]: 
2014-03-13T08:30:22.554354+00:00 app[web.1]:     at Protocol.end (/app/node_modules/mysql/lib/protocol/Protocol.js:78:13)
2014-03-13T08:30:22.554354+00:00 app[web.1]:     at Socket.<anonymous> (/app/node_modules/mysql/lib/Connection.js:78:28)
2014-03-13T08:30:22.554354+00:00 app[web.1]: Error: Connection lost: The server closed the connection.
2014-03-13T08:30:22.554354+00:00 app[web.1]:     at Socket.EventEmitter.emit (events.js:117:20)
2014-03-13T08:30:22.554354+00:00 app[web.1]:     at _stream_readable.js:920:16
2014-03-13T08:30:22.554354+00:00 app[web.1]:     at process._tickCallback (node.js:415:13)
2014-03-13T08:30:24.327286+00:00 heroku[web.1]: Process exited with status 8

When I test this locally (with foreman or without), and it works! I have added my IP address in Authorized Networks for Google Cloud SQL, and as well as my applications's IP address.

I have used http://www.hcidata.info/host2ip.cgi to find out my web app's IP address.

Can anyone had same experience?

like image 751
user3414398 Avatar asked Mar 13 '14 08:03

user3414398


1 Answers

Your problem may be similar to the one in this question:

Your problem may be that Cloud SQL is not allowing your Dyno's IP address. Because the Heroku dyno grid is dynamic in nature, the IP address that a given dyno will be assigned over time will be both dynamic and unpredictable.

As mentioned in the other question, you can use a proxy Heroku add-on that would give you a static IP.

A workaround can be to whitelist 0.0.0.0/0 (all possible IP addresses) within your Cloud SQL instance. If you do so, I highly recommend requiring SSL for your database connection.

like image 136
Steren Avatar answered Nov 12 '22 08:11

Steren