CLOUD_SQL_CONNECTION_TIMEOUT cloud network_error ai_generated true

Error: SQL Server connection timeout after 30 seconds using Cloud SQL Proxy with SSL

ID: cloud/gcp-cloud-sql-connection-timeout-ssl

Also available as: JSON · Markdown · 中文
80%Fix Rate
85%Confidence
1Evidence
2023-08-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
Cloud SQL Proxy 2.8.0 active
Cloud SQL for SQL Server 2022 active
gcloud CLI 450.0.0 active

Root Cause

Cloud SQL Proxy with SSL enabled can cause connection timeouts when the proxy's SSL handshake is misconfigured or the instance's SSL certificate is not properly trusted, leading to a 30-second default connection timeout.

generic

中文

当 Cloud SQL Proxy 启用了 SSL 但 SSL 握手配置错误或实例的 SSL 证书未正确信任时,会导致连接超时,默认超时时间为 30 秒。

Official Documentation

https://cloud.google.com/sql/docs/sqlserver/connect-connector

Workarounds

  1. 85% success Update the Cloud SQL Proxy to the latest version (e.g., 2.9.0+) and ensure the SSL certificate chain is correctly configured: download the server CA certificate from the GCP Console and pass it via --ssl-ca-path.
    Update the Cloud SQL Proxy to the latest version (e.g., 2.9.0+) and ensure the SSL certificate chain is correctly configured: download the server CA certificate from the GCP Console and pass it via --ssl-ca-path.
  2. 75% success Use the Cloud SQL Auth Proxy with the --auto-iam-authn flag to bypass SSL certificate issues when IAM authentication is enabled.
    Use the Cloud SQL Auth Proxy with the --auto-iam-authn flag to bypass SSL certificate issues when IAM authentication is enabled.
  3. 80% success Example command: cloud-sql-proxy --ssl-ca-path=/path/to/server-ca.pem INSTANCE_CONNECTION_NAME
    Example command: cloud-sql-proxy --ssl-ca-path=/path/to/server-ca.pem INSTANCE_CONNECTION_NAME

中文步骤

  1. 将 Cloud SQL Proxy 更新到最新版本(例如 2.9.0+),并确保 SSL 证书链配置正确:从 GCP 控制台下载服务器 CA 证书,并通过 --ssl-ca-path 参数传递。
  2. 使用 Cloud SQL Auth Proxy 的 --auto-iam-authn 标志,在启用了 IAM 认证时绕过 SSL 证书问题。
  3. 示例命令:cloud-sql-proxy --ssl-ca-path=/path/to/server-ca.pem INSTANCE_CONNECTION_NAME

Dead Ends

Common approaches that don't work:

  1. 70% fail

    The timeout is a symptom, not the root cause; the SSL handshake still fails.

  2. 50% fail

    SSL is often required by compliance; disabling it is not a viable fix.