What could cause a connection to a Google Cloud SQL instance to fail even with the ip registered in the list of allowed addresses? - google-cloud-sql

I am unable to connect to a Google Cloud SQL instance. I get the error: [MySQL] [ODBC 5.1 Driver] Can't connect to MySQL server on 'XX.XXX.XX.XXX' (10060)
The IP from which I try to connect is a fixed ip and is registered in the list of allowed IPs in the Cloud SQL instance.
The machine that needs to connect is a Windows server with Windows Server 2016 operating system and can connect to other instances of Google Cloud SQL. We only have problems connecting to this instance. Another detail of the error is that the ping performed on my Windows instance returns total loss in relation to the Cloud SQL instance IP. Finally, I can access the databases using my local internet or another server.
I will be very grateful if someone can give me a tip to identify the problem

Related

Has someone connected a PostgreSQL DB hosted in GCloud with Microsoft SSMS?

I have a question, I do not know how to solve it yet. Perhaps someone here has faced a similar issue.
We have a PostgreSQL DB hosted on Gcloud. We usually use a cloud proxy to connect with the database. It usually works very well!! In a nutshell the proxy connect a port from local host, to the actual DB host.
However this time, we want to connect it with Microsoft SSMS. We have not find an option where we can connect Microsoft SSMS with a DB running locally (this means connecting to a database on a port in local host).
The ultimate goal is to connect the database with Power BI. So if someone know how to connect a PostgreSQL DB hosted in GCloud to power BI that would also be very helpful!!
We have followed this tutorial:
https://www.anibalum.com.ar/2020/06/creating-linked-server-with-postgres.html
However we get the following error:
The linked server has been created but failed a connection test. Do you want to keep the linked server?
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Cannot initialize the data source object of OLE DB provider "MSDASQL" for linked server "PAPERFLOWDB".
OLE DB provider "MSDASQL" for linked server "PAPERFLOWDB" returned message "[Microsoft][ODBC Driver Manager] Invalid connection string attribute".
OLE DB provider "MSDASQL" for linked server "PAPERFLOWDB" returned message "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified". (Microsoft SQL Server, Error: 7303)
We are using Microsoft SSMS v18.9.1

What could I be missing with Prisma client, Cloud Run, and Cloud SQL - my Prisma client can't socket-connect to my Cloud SQL instance DB?

Background
I have a NestJS project with Prisma ORM, and I am continually receiving the error:
PrismaClientInitializationError: Can't reach database server at `localhost`:`5432`
This is happening during the Cloud Build Deploy step.
Since this is a containerized application (attempting to) run in a Cloud Run instance, I'm supposed to use a socket connection. Here's the documentation from Prisma on connecting to a Postgres DB through a socket connection: https://www.prisma.io/docs/concepts/database-connectors/postgresql#connecting-via-sockets
Connecting via sockets
To connect to your PostgreSQL database via sockets, you must add a host field as a query parameter to the connection URL (instead of setting it as the host part of the URI). The value of this parameter then must point to the directory that contains the socket, e.g.: postgresql://USER:PASSWORD#localhost/database?host=/var/run/postgresql/
Note that localhost is required, the value itself is ignored and can be anything.
I've done this to the letter, as described in the Cloud SQL documentation, with the exception that I percent-encoded my path to the directory containing the socket. I've included and excluded the trailing slash.
So my host var looks like this, mapped from the percent-encoded values:
/cloudsql/<MY CLOUD SQL CONNECTION NAME>/<DB>
I've read over the Cloud Run documentation, and in my mind, I should expect a different error if the instance itself can't connect to the Cloud SQL instance. I've followed the "Make sure you have the appropriate permissions and connection" from the documentation a few times now.
Is there anything obvious that I'm missing? Am I wrong about an error related to Cloud Run instance just not connecting with Cloud SQL instance?
Things I've tried & things I know
I CAN connect directly to the Cloud SQL instance locally through psql
I CAN run a local server with the Cloud SQL instance public IP and establish a client connection & interact with the database
I CAN successfully create an image and run a container from that image locally
My big concern
It doesn't make sense to me in which order things should connect to the Cloud SQL instance. To me, the Cloud Run - Cloud SQL connection MUST be established before the application run inside the Cloud Run instance can establish its connection through the socket to the Cloud SQL instance. -- Am I thinking through that correctly?

Azure Data Factory - copy data from PostgreSQL on VM

I am trying to pull data from Postgresql on Azure using Azure Data Factory but have no luck. Both ADF and VM are in the same Azure Vnet.
In my VM networking settings I allowed port 5432 inbound access from ADF to VirtualNetwork. Similar outbound vnet to vnet.
I also installed ODBC driver on VM and added it to firewall.
I installed also the selfhosted integration runtime on VM which connects to ADF.
When creating a new Linked Service on ADF I chose PostgreSQL as source.
Not able to establish connection though.
Tried different settings:
-IP and DNS as servername
-self hosted and auto resolve integration runtime
-public and private IP
-no encryption and encryption
-temporarily turned off firewall on vm to test
still no success.
What am I missing?
password and database names are correct.
The error message I am getting when testing connection:
Error code
9603
Details
ERROR [08001] [Microsoft][ODBC PostgreSQL Wire Protocol driver]Connection refused. Verify Host Name and Port Number.
ERROR [HY000] [Microsoft][ODBC PostgreSQL Wire Protocol driver]Can't connect to server on 'xx.xxx.xxx.xx'
I would appreciate it if anyone could help.
Thank you
I found the solution. I need to use the ODBC connector as a linked service on ADF, not the PostgreSQL connector. Bingo!

ERROR 2013 (HY000) while connecting to Google Cloud Sql MySql database from mysql client

Since yesterday, I am getting the following error while trying to connect to my Google Cloud SQL MySql database:
ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 0
My app is able to connect to the database, but I am unable to connect from my computer. I have configured my public ip address in Access Controls section.
I noticed one other thing. The public address I setup is not stored, and when I come back to the "Access Control" tab I see a different ip address from what I saved.
How do I access my Cloud SQL MySql instance through MySql client? Is there any other setting I need to do?
I figured this was a browser problem. The Google developer console on Mozilla was displaying the ip as updated although it was not updating it in the backend. I used Chrome to set this Access control in the Developer console and this worked fine.

Google Cloud SQL: SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 0

I'm desperate since my Google Cloud SQL instance went down. I could connect to it yesterday without problem but since this morning i'm unable to connect to it in any way, it produces the following error: The database server returned this error: SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 0
This is what I did to try to fix this:
restart instance
added authorized ip-addresses in CIDR notation
reset root password
restored backup
pinged the ip-address and I get response
All these actions completed but i'm still unable to connect through:
PHP
MySQL workbench
Ubuntu MySQL command line
All without luck. What could I do to repair my Cloud SQL instance. Is anyone else having this problem?
I'm from the Cloud SQL team. We are looking into this issue, it should be resolved soon. See https://groups.google.com/forum/#!topic/google-cloud-sql-announce/SwomB2zuRDo. Updates will be posted on that thread (and if there's anything particularly important I'll edit this post).
The problem seems to only affect connections from outside Google Cloud. Clients connecting from App Engine and Compute Engine should work fine.
Our company has same problem.
We are unable to connect through both MySQL workbench and MySQL command line.
Our Google Appengine application has no problems to connect since its not using external IP.
there.I encountered the same problem.You need to find out your public ip address,for that type "my public ip" in Google.Now click on your Cloud SQL instance that you created,under that click on ACCESS CONTROL tab and then click on Authorization tab under that.Under Authorized network,give any name you want to the network and copy your public ip address in the network.Now save changes and try to run the command from console.It should work fine.