We've been using Cloud SQL for months without problems. Today we started to get a lot of HTTP 500 errors on our application logs. Upon debugging, we found out that the cause was that the private IP of our Cloud SQL PostgreSQL instance changed from 10.96.96.2 to 10.96.96.3, hence the app was unable to connect to the backend DB.
According to this doc: https://cloud.google.com/sql/docs/postgres/private-ip
The private IP address of the Cloud SQL instance is static; it does not change.
Did any of you experience something like this before? Is there any way to specify some kind of "internal hostname" instead of using the IP address directly?
Thanks
UPDATE
Official answer from Google after reporting this issue:
After reviewing your issue I found that the change on the private ip of your PostgreSQL instance was produced after a scheduled maintenance rollout.
Please point your connections to the new private ip
Regarding to your question, as you correctly mentioned previously this isn’t an common behaviour of the statics ip's on Cloud SQL so you don’t need to take further actions in order to avoid this happening in the future.
You should open a private issue on the Cloud SQL issue tracker, making sure to note that time in happened, as well as the project and instance id. The support team will be able to take a look (if you have a support package, open a support ticket instead as you will get a faster response).
For the second part, you can use the Cloud SQL proxy to connect to an instance by the connection name. Make sure you that you use the flag
-ip_address_types=PRIVATE
to ensure the proxy connects via it's private ip.