Python 2.7 已終止支援,並將於 2026 年 1 月 31 日
淘汰。淘汰後,您將無法部署 Python 2.7 應用程式,即使貴機構先前曾使用機構政策重新啟用舊版執行階段的部署作業,也無法部署。現有的 Python 2.7 應用程式在
淘汰日期過後,仍會繼續執行並接收流量。建議您
改用系統支援的最新 Python 版本。
App Engine 連線問題
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本頁說明常用的 App Engine 連線策略,包括使用 無伺服器虛擬私有雲存取和內部 IP 位址的相關步驟。
從虛擬私有雲連線至 App Engine 執行個體
從 Google 的無伺服器服務對虛擬私有雲端 (VPC) 網路發出呼叫時,無伺服器虛擬私人雲端存取功能就很實用,但您無法使用內部 IP 位址存取 App Engine 執行個體。
如要使用內部 IP 位址 (沒有指派的外部 IP 位址) 從虛擬私有雲網路連線至 App Engine,請執行下列步驟:
- 設定私人 Google 存取權。請確認 App Engine 服務使用啟用私人 Google 存取權的子網路。
- 使用 Private Service Connect 端點。請確認端點已連線至已啟用私人 Google 存取權的子網路。
- 將流量傳送至 Private Service Connect 端點。確認端點已連上子網路。
具有外部 IP 位址的 App Engine 執行個體可以將流量傳送至 Private Service Connect 端點,無須符合任何條件。
傳出連線重設
Google Cloud 在更新或重新啟動基礎架構時,可能會不時終止並取代應用程式與 VPC 和網際網路的連線串流。如果應用程式重複使用長效連線,建議您將應用程式設為重新建立連線,以免重複使用已中斷的連線。
自訂 App Engine 服務之間的存取權限
如果您有多個 App Engine 服務,且想在各服務之間設定不同的存取權限 (例如,您只想在 App Engine 服務 B 中啟用 App Engine 服務 A 的存取權),可以使用搭配 Identity-Aware Proxy (IAP) 的 App Engine。
詳情請參閱「控管對網站和應用程式的存取權」和 IAP 說明文件。
將 App Engine 連線至 Cloud SQL 私人 IP 位址
如要透過私人 IP 位址將 App Engine 應用程式連線至 Cloud SQL 執行個體,請使用下列任一選項:
排解將 App Engine 應用程式連線至 Cloud SQL 的問題
當您使用 Unix 通訊端部署舊版 App Engine 標準環境應用程式 (搭配 Cloud SQL) 時,如果應用程式未正確設定,無法連線至 Cloud SQL 執行個體,您可能會看到幾則錯誤訊息。如要瞭解設定應用程式的詳細步驟,請參閱「從 App Engine 標準環境連線」一文。
下列警告訊息表示 App Engine 能夠改用舊版連線方法,順利完成作業:
CloudSQL warning: your action is needed to update your application and avoid potential disruptions. Please see https://cloud.google.com/sql/docs/mysql/connect-app-engine-standard for additional details: ...
以下錯誤訊息表示連線至 Cloud SQL 的作業未順利完成:
Cloud SQL connection failed. Please see https://cloud.google.com/sql/docs/mysql/connect-app-engine-standard for additional details: ...
針對這兩種錯誤訊息,請檢查下列項目,確保 Cloud SQL 驗證 Proxy 已正確設定,可連線至 Cloud SQL 執行個體:
- 您必須啟用 Cloud SQL Admin API。
- App Engine 應用程式的服務帳戶必須具備正確的權限。
- 執行個體連線名稱必須包含區域。
如果在疑難排解後仍持續收到失敗訊息,請與Google Cloud 支援團隊聯絡尋求協助。
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-09-04 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[[["\u003cp\u003eServerless VPC Access facilitates connections from Google's serverless offerings to a Virtual Private Cloud (VPC), but it does not allow direct access to App Engine instances using internal IP addresses.\u003c/p\u003e\n"],["\u003cp\u003eConnecting to App Engine from a VPC network with an internal IP address requires setting up Private Google Access and using a Private Service Connect endpoint.\u003c/p\u003e\n"],["\u003cp\u003eWhen you have multiple App Engine services and you need to restrict access between them, you can utilize App Engine with Identity-Aware Proxy (IAP) to control permissions.\u003c/p\u003e\n"],["\u003cp\u003eApp Engine apps can connect to Cloud SQL instances over private IP addresses using either the Serverless VPC Access connector for standard environments or by deploying the app within the same VPC network as the Cloud SQL instance for flexible environments.\u003c/p\u003e\n"],["\u003cp\u003eTroubleshooting connection failures between App Engine and Cloud SQL often involves ensuring the Cloud SQL Admin API is enabled, the service account has correct permissions, and the instance connection name is correctly formatted, which will involve the region.\u003c/p\u003e\n"]]],[],null,["# App Engine connectivity questions\n\nThis page describes commonly used App Engine connectivity\nstrategies, including steps related to using [Serverless VPC Access](/vpc/docs/serverless-vpc-access) and internal IP addresses.\n\n- [Connect from VPC to App Engine instances](#set-up-connectivity-from-vpc-to-app-engine)\n- [Connect App Engine to Cloud SQL private IP addresses](#sql-connectivity)\n- [Customize access permissions between App Engine services](#access-permissions)\n\nConnect from VPC to App Engine instances\n----------------------------------------\n\nServerless VPC Access is useful when making calls from Google's\nserverless offerings to a Virtual Private Cloud (VPC) network, but you can't\naccess App Engine instances using an internal IP address.\n\nTo connect to App Engine from the VPC network using an\ninternal IP address without an assigned external IP address, do the following:\n\n1. Set up [Private Google Access](/vpc/docs/private-google-access). Ensure that the App Engine service uses a Private Google Access-enabled subnet.\n2. Use a [Private Service Connect](/vpc/docs/private-service-connect) endpoint. Ensure that the endpoint is connected to the Private Google Access-enabled subnet.\n3. Send traffic to the Private Service Connect endpoint. Ensure that the endpoint is connected to the subnet.\n\nApp Engine instances with external IP addresses can send traffic to\nPrivate Service Connect endpoints without any requirements.\n\n### Outbound connection resets\n\nGoogle Cloud can occasionally terminate and replace connection streams from your\napplication to both [VPC](/appengine/docs/standard/connecting-vpc)\nand the internet when updating or restarting the underlying infrastructure. If your application reuses long-lived connections, we recommend that you configure your application to\nre-establish connections to avoid the reuse of a dead connection.\n\nCustomize access permissions between App Engine services\n--------------------------------------------------------\n\nWhen you have multiple App Engine services and\nwant to configure access permissions differently between services (for example,\nyou want to enable access to App Engine Service A only from App Engine Service B), you can use\n[App Engine with Identity-Aware Proxy (IAP)](/solutions/authenticating-web-users).\n\nFor more information, see [Controlling access to websites and apps](/solutions/authenticating-web-users) and [IAP documentation](/iap/docs/authenticate-users-google-accounts).\n\nConnect App Engine to Cloud SQL private IP addresses\n----------------------------------------------------\n\nTo connect your App Engine apps to [Cloud SQL](/sql)\ninstances over private IP addresses, use one of the following options:\n\n- **App Engine standard environment** : Use the [Serverless VPC Access connector](/vpc/docs/serverless-vpc-access) to connect to Cloud SQL over internal IP addresses. For more information, see [Connecting from App Engine standard environment to Cloud SQL](/sql/docs/mysql/connect-app-engine-standard#configuring).\n- **App Engine flexible environment** : Deploy your flexible environment app in the same VPC network as your Cloud SQL instance. Your app should now be able to connect directly using Cloud SQL instance's private IP address. For more information, see [Connecting from App Engine flexible environment to Cloud SQL](/sql/docs/mysql/connect-app-engine-flexible#configuring).\n\n### Troubleshoot issues connecting an App Engine app to Cloud SQL\n\nWhen deploying an older App Engine standard environment app with Cloud SQL using Unix\nsockets, you might see a few error messages if your app isn't correctly\nconfigured to connect to a Cloud SQL instance. For detailed steps to\nconfigure your app, see [Connect from App Engine standard environment](/sql/docs/mysql/connect-app-engine-standard#configure).\n\nThe following warning message indicates that App Engine was able to fall\nback on a legacy connection method to complete the operation successfully: \n\n```\nCloudSQL warning: your action is needed to update your application and avoid potential disruptions. Please see https://cloud.google.com/sql/docs/mysql/connect-app-engine-standard for additional details: ... \n```\n\nThe following error message indicates that the operation to connect to\nCloud SQL wasn't completed successfully: \n\n```\nCloud SQL connection failed. Please see https://cloud.google.com/sql/docs/mysql/connect-app-engine-standard for additional details: ...\n```\n\nFor both error messages, check the following to ensure that the\n[Cloud SQL Auth proxy](/sql/docs/mysql/connect-admin-proxy) is correctly\nconfigured to connect to a Cloud SQL instance:\n\n- The Cloud SQL Admin API must be enabled.\n- The service account for the App Engine app must have the correct permissions.\n- The instance connection name must include the region.\n\nIf the failure message persists after troubleshooting, contact\n[Google Cloud Support](https://support.google.com/cloud/#topic=3473162)\nfor assistance."]]