I'm having a strange behavior with Cloud SQL Proxy.
If I manually start the process, using the following command, it works ok from any IP on my network, as desired:
./cloud_sql_proxy -instances=<INSTANCE NAME>=tcp:0.0.0.0:5004
But if I setup it to run as a service, it doesn´t work by any means. This is how the service file looks like:
[Unit]
Description=Google Cloud SQL Proxy
After=network.target
[Service]
Type=simple
ExecStart=/path/path/cloud_sql_proxy -instances=<INSTANCE NAME>=tcp:0.0.0.0:5004
Restart=always
[Install]
WantedBy=multi-user.target
In this last case the client shows a "server refused connection" advice, so it means the server is actually reached. I'm running this on a Raspberry Pi with Raspbian. Anyone knows what I am doing wrong? Thanks!!
I tried changing the port, verifing that the process runs, eliminating the Address declaration on the command. Nothing seems to work.
When you run the proxy as a service, you are using a different OS user - the root user.
Your command is using Application Default Credentials. If those credentials are set up using the command gcloud auth application-default login
, then those credentials are only available to the same user.
If you are setting up credentials via another method, then you must repeat that process for the root user or specify the credentials via the command line flag --credentials-file=/path/to/service-account.json
.
Refer to this link for details on authorization.