GCP has this
cloud_sql_proxy tool that provides conceivably secure connection to your Cloud SQL instances, PostgreSQL, MySQL, SQL, whatever it might be the case. Think of it as an auth proxy for your privately accessed databases, meaning being deployed in a private subnet, without attaching any public IP address, you get me. Now, there are three ways to setup the connection including: TCP sockets, Unix sockets, and at last, Docker. In this post, I’ll show you how to stop, close an already existing, active auth proxy connection.
- GCP Cloud SQL
- Cloud SQL Auth proxy tool
Step 1. First, find the process ID.
ps aux | grep "cloud_sql_proxy*"
Step 2. Kill the process.
kill -9 <PID>
-9: being the KILL signal.
The proper, correct, ideal way to disconnect a Unix socket, would be from the application itself, the service that created the socket in the first place. But, there is alternative solution too. A “quick” fix if you will, using the
Step 1. Install the
apt get install -y dsniff
Step 2. Close the connection socket.
tcpkill -i eth0 host <ipv4_address> and port <port_number>
Finally, the least hustle possible with Docker though. Just stop the Docker container. For instance:
docker stop cloud_sql_proxy
cloud_sql_proxy with any Docker container name assigned from your side.
If you have any other great solutions on this topic, or even issues, feel free to leave a comment below and if you find this tutorial useful, follow our official channel on Telegram.