About the Cloud SQL Auth Proxy

MySQL  |  PostgreSQL  |  SQL Server

This page summarizes the Cloud SQL Auth Proxy and describes how to use it to establishauthorized, encrypted, and secured connections to your instances.

For step-by-step instructions on using the Cloud SQL Auth Proxy, follow the linkfor your environment:

You do not need to use the Cloud SQL Auth Proxy or configure SSL to connect toCloud SQL fromApp Engine standard environmentorApp Engine flexible environment.

Benefits of the Cloud SQL Auth Proxy

TheCloud SQL Auth Proxy is a Cloud SQL connector that provides secure access to yourinstances withouta need forAuthorized networksor forconfiguring SSL.

The Cloud SQL Auth Proxy andother Cloud SQL Connectors have thefollowing benefits:

  • Secure connections: The Cloud SQL Auth Proxy automatically encrypts traffic to andfrom the database using TLS 1.3 with the cipher selection determined byGo's rules. SSL certificates are usedto verify client and server identities, and are independent of databaseprotocols; you won't need to manage SSL certificates.
  • Easier connection authorization: The Cloud SQL Auth Proxy uses IAM permissions tocontrol who and what can connect to your Cloud SQL instances. Thus, theCloud SQL Auth Proxy handles authentication with Cloud SQL, removing the need to providestatic IP addresses.
  • IAM database authentication. Optionally, the Cloud SQL Auth Proxy supports anautomatic refresh of OAuth 2.0 access tokens. For information about thisfunctionality, seeCloud SQL IAM database authentication.

The Cloud SQL Auth Proxy does not provide a new connectivity path; it relies on existing IPconnectivity. To connect to a Cloud SQL instance usingprivate IP, the Cloud SQL Auth Proxy must be on a resource with accessto the same VPC network as the instance.

If you're using the Java, Python, or Go languages, thenconnect with the corresponding connector instead of with the Cloud SQL Auth proxy.

Limitations

You can't use the Cloud SQL Auth Proxy if you're usingcontext-aware access andIAM database authentication. When you try to login to the instance,IAM authentication fails.

How the Cloud SQL Auth Proxy works

The Cloud SQL Auth Proxy works by having a local client runningin the local environment. Your application communicates with the Cloud SQL Auth Proxywith the standard database protocol used by your database.

The Cloud SQL Auth Proxy uses a secure tunnel to communicate with its companion processrunning on the server. Each connection established through the Cloud SQL Auth Proxy createsone connection to the Cloud SQL instance.

When an application connects to Cloud SQL Auth Proxy, it checks whether an existingconnection between it and the target Cloud SQL instance is available.If a connection does not exist, it calls Cloud SQL Admin APIs to obtainan ephemeral SSL certificate and uses it to connect to Cloud SQL.Ephemeral SSL certificates expire in approximately an hour. Cloud SQL Auth Proxy refreshesthese certificates before they expire.

Note: You must allow outgoing (or egress) TCPconnections to ports443 and3307.

For more information about these ports, seeLog in with automatic IAM database authentication.

The Cloud SQL Auth Proxy doesn't provideconnection pooling,but can be paired with other connection pooling to increase efficiency.

Note: The connection between the client applications and the Cloud SQL Auth Proxy client on the client machine is not encrypted. We recommend that you run the proxy on the same machine that contains your workload.

The following diagram shows how the Cloud SQL Auth Proxy connects to Cloud SQL:

Diagram of the Cloud SQL Auth Proxy connecting from client software to SQL instance

Requirements for using the Cloud SQL Auth Proxy

To use the Cloud SQL Auth Proxy, you must meet the following requirements:

If the Cloud SQL instance to which you're connecting is usingshared certificate authority (CA)for itsserverCaMode setting,then on the client side, you must use Cloud SQL Auth Proxy version 2.13.0 or later.

If the Cloud SQL instance to which you're connecting is usingcustomer-managed CAfor itsserverCaMode setting,then on the client side, you must use Cloud SQL Auth Proxy version 2.14.3 or later.

When an instance uses customer-managed CA as its server CA mode, you can configurethe instance with acustom DNS name.You provide the custom DNS name in thecustom subject alternative name (SAN) field of the server certificate.

After you set up a custom DNS name for the instance, you can connect to theinstance from Cloud SQL Language Connectors using the DNS name.

Download and install the Cloud SQL Auth Proxy

Linux 64-bit

  1. Download the Cloud SQL Auth Proxy:
    curl-ocloud-sql-proxyhttps://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.18.0/cloud-sql-proxy.linux.amd64
  2. Make the Cloud SQL Auth Proxy executable:
    chmod+xcloud-sql-proxy

Linux 32-bit

  1. Download the Cloud SQL Auth Proxy:
    curl-ocloud-sql-proxyhttps://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.18.0/cloud-sql-proxy.linux.386
  2. If thecurl command is not found, runsudo apt install curl and repeat the download command.
  3. Make the Cloud SQL Auth Proxy executable:
    chmod+xcloud-sql-proxy

macOS 64-bit

  1. Download the Cloud SQL Auth Proxy:
    curl-ocloud-sql-proxyhttps://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.18.0/cloud-sql-proxy.darwin.amd64
  2. Make the Cloud SQL Auth Proxy executable:
    chmod+xcloud-sql-proxy

Mac M1

  1. Download the Cloud SQL Auth Proxy:
    curl-ocloud-sql-proxyhttps://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.18.0/cloud-sql-proxy.darwin.arm64
  2. Make the Cloud SQL Auth Proxy executable:
    chmod+xcloud-sql-proxy

Windows 64-bit

Right-clickhttps://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.18.0/cloud-sql-proxy.x64.exe and selectSave Link As to download the Cloud SQL Auth Proxy. Rename the file tocloud-sql-proxy.exe.

Windows 32-bit

Right-clickhttps://storage.googleapis.com/cloud-sql-connectors/cloud-sql-proxy/v2.18.0/cloud-sql-proxy.x86.exe and selectSave Link As to download the Cloud SQL Auth Proxy. Rename the file tocloud-sql-proxy.exe.

Cloud SQL Auth Proxy Docker image

The Cloud SQL Auth Proxy has different container images, such asdistroless,alpine,andbuster. The default Cloud SQL Auth Proxy container image usesdistroless, whichcontains no shell. If you need a shell or related tools, then download an image based onalpine orbuster.For more information, seeCloud SQL Auth Proxy Container Images.

You can pull the latest image to your local machine using Docker by using the following command:

docker pull gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.18.0

Note: The Cloud SQL Auth Proxy uses a repository that supports thegcr.io domain but serves images from Artifact Registry. For more information, seeTransition from Container Registry.

Other OS

For other operating systems not included here, you cancompile the Cloud SQL Auth Proxy from source.
Note: For Cloud SQL Auth Proxy version 2.17.1 and later, the Cloud SQL Auth Proxy Windows binaries are digitally signed with a Google certificate.

Cloud SQL Auth Proxy startup options

When you start the Cloud SQL Auth Proxy, you provide it with the following information:

  • What Cloud SQL instances to establish connections to
  • Where it will listen for data coming from your application to be sentto Cloud SQL
  • Where it will find the credentials it will use to authenticate yourapplication to Cloud SQL
  • If required, which IP address type to use.

The Cloud SQL Auth Proxy startup options you provide determine whether it will listen on a TCPport or on a Unix socket. If it is listening on a Unix socket, it creates thesocket at the location you choose; usually, the /cloudsql/ directory.For TCP, the Cloud SQL Auth Proxy listens onlocalhost by default.

Run thecloud-sql-proxy executable with the argument--help toview the complete list of startup options.

Note: The Cloud SQL Auth Proxy does not support Unix sockets on Windows. Linux-basedoperating systems have a maximum socket path length of 108 characters. If thetotal length of the path exceeds this length, you cannot connect.

You can install the Cloud SQL Auth Proxy anywhere in your local environment. The location ofthe Cloud SQL Auth Proxy binaries does not impact where it listens for data from yourapplication.

For more information about how to start the Cloud SQL Auth Proxy, seeStart the Cloud SQL Auth Proxy.

Use a service account for authentication

The Cloud SQL Auth Proxy requires authenticating as a Cloud SQL IAM identityto authorize your connections to a Cloud SQL instance.

The advantage of using a service account forthis purpose is that you can create a credential file specifically for theCloud SQL Auth Proxy, and it is explicitly and permanently linked to the Cloud SQL Auth Proxy as long as it isrunning. For this reason, using a service account is the recommended method for productioninstances not running on a Compute Engine instance.

The credential file can be duplicated in a system image if you need to invokethe Cloud SQL Auth Proxy from multiple machines.

To use this method, you must create and manage the credential file. Only userswith theresourcemanager.projects.setIamPolicy permission(such as project owners) can create the service account. If yourGoogle Cloud user does not have this permission, you must have someoneelse create the service account for you, or use another method toauthenticate the Cloud SQL Auth Proxy.

Learn how to Create a service account.

Required permissions for service accounts

When you use a service account to provide the credentials for the Cloud SQL Auth Proxy, youmust create it with sufficient permissions. If you are using the finer-grainedIdentity Access and Management (IAM) roles to manage yourCloud SQL permissions, you must give the service account a role thatincludes thecloudsql.instances.connect permission. The predefinedCloud SQL roles that include this permission are:

  • Cloud SQL Client
  • Cloud SQL Editor
  • Cloud SQL Admin

If you are using the legacy project roles (Viewer, Editor, Owner), the serviceaccount must have at least the Editor role.

Keep the Cloud SQL Auth Proxy up to date

Google occasionally releases new versions of the Cloud SQL Auth Proxy. You can see what thecurrent version is by checking theCloud SQL Auth Proxy GitHub releases page.Future proxy releases will also be noted in theGoogle Groups Cloud SQL announce forum.

Note: you must be running version 1.12 or later to connect usingprivate IP.

API usage

The Cloud SQL Auth Proxy issues requests to the Cloud SQL Admin API. These requests countagainst the API quota for your project.

The highest API usage occurs when you start the Cloud SQL Auth Proxy. While theCloud SQL Auth Proxy is running, it issues 2 API calls per hour per connected instance.

Cloud SQL Auth Proxy parameters and flags

The Cloud SQL Auth Proxy accepts several flags and parameters when it is started. Theseoptions determine where and how the Cloud SQL Auth Proxy creates the sockets it uses forcommunicating with Cloud SQL, and how it authenticates.

For help with Cloud SQL Auth Proxy options, see the following information:

Use the Cloud SQL Auth Proxy in a production environment

When you are using the Cloud SQL Auth Proxy in a production environment, there are somesteps you can take to ensure that the Cloud SQL Auth Proxy provides the requiredavailability for your application.

Ensure that the Cloud SQL Auth Proxy is run as a persistent service

If the Cloud SQL Auth Proxy process is stopped, all existing connections through it aredropped, and your application cannot create any more connections to theCloud SQL instance with the Cloud SQL Auth Proxy. To prevent this scenario, be sure torun the Cloud SQL Auth Proxy as a persistent service, so that if the Cloud SQL Auth Proxy exits for anyreason, it is automatically restarted. This can be accomplished by using aservice such assystemd,upstart, orsupervisor. For the Windows operatingsystem, run the Cloud SQL Auth Proxy as a Windows Service. In general, make sure the Cloud SQL Auth Proxy hasthe same uptime requirements as your application process.

Note: The Cloud SQL Auth Proxy is a Windows executable but is not a Windows Service.There are several tools available that can wrap a regular application binary asa service.

How many copies of the Cloud SQL Auth Proxy your application needs

There is no need to create a proxy process for every application process; manyapplication processes can share a single Cloud SQL Auth Proxy process. Run one Cloud SQL Auth Proxy clientprocess per workstation or virtual machine.

If you are using auto-scaling for virtual machines, ensure that the Cloud SQL Auth Proxyis included in your virtual machine configuration, so that whenever a newvirtual machine is started, it has its own Cloud SQL Auth Proxy process.

It is up to you to manage how many connections your application requires,whether by limiting or pooling the connections. The Cloud SQL Auth Proxy does not place anylimitations on new connection rates or persistent connection count.

Reduce Cloud SQL Auth Proxy output

If you need to reduce the size of the Cloud SQL Auth Proxy log, you can do so by setting--quiet when you start the Cloud SQL Auth Proxy. Keep in mind, however, that doingso reduces the effectiveness of the Cloud SQL Auth Proxy output in diagnosing connectionissues.

How failover affects the Cloud SQL Auth Proxy

If you are running the Cloud SQL Auth Proxy on an instance configured for High Availability,and a failover occurs, connections through the Cloud SQL Auth Proxy are affected the same wayas connections over IP: all existing connections are lost, and the applicationmust establish new connections. However, no manual intervention is required; theapplication can continue using the same connection strings it was before.

Keep the Cloud SQL Auth Proxy Docker image up to date

The Cloud SQL Auth Proxy Docker image is based on a specific version of the Cloud SQL Auth Proxy.When a new version of the Cloud SQL Auth Proxy becomes available, pull the newversion of the Cloud SQL Auth Proxy Docker image to keep your environment up to date. Youcan see the current version of the Cloud SQL Auth Proxy by checking theCloud SQL Auth Proxy GitHub releases page.

How to enforce use of the Cloud SQL Auth Proxy

You can enforce the use of the Cloud SQL Auth Proxy in Cloud SQL instance connections usingConnectorEnforcement.With connector enforcement, direct database connection are rejected.

To use connector enforcement, you use theConnectorEnforcement field in theinstances API.

If you're using aPrivate Service Connect-enabled instance, then there's a limitation. If the instance has connector enforcement enabled, then you can't create read replicas for the instance. Similarly, if the instance has read replicas, then you can't enable connector enforcement for the instance.

For more information about how to enforce using only the Cloud SQL Auth Proxy or Cloud SQL Language Connectors to connect to an instance, seeEnforce the use of the Cloud SQL Auth Proxy.

About the Cloud SQL Proxy Operator

Cloud SQL Proxy Operator is an open-source Kubernetes operator that automatesconnecting workloads in a GKE cluster to Cloud SQL databases. TheCloud SQL Auth Proxy Operator utilizes a custom resource AuthProxyWorkload that specifiesthe Cloud SQL Auth Proxy configuration for a specific workload. The Cloud SQL Auth Proxy Operatorreads this resource and adds a Cloud SQL Auth Proxy container with the required configurationto the appropriate workloads.

When you install the operator in your GKE cluster and configure your workloadsand Cloud SQL instances, the Cloud SQL Auth Proxy Operator automatically configures theCloud SQL Auth Proxy and connects the GKE workloads to your Cloud SQL instances.

Cloud SQL Auth Proxy Operator also checks the status of the Cloud SQL Auth Proxy. If the Cloud SQL Auth Proxyis unable to connect, the Cloud SQL Auth Proxy Operator outputs debugging information,and provides you with guidance to troubleshoot and repair common configurationissues.

For more information, seeConnect using the Cloud SQL Proxy Operator.

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-07-14 UTC.