Connecting from App Engine

This page provides language-specific links to informaton about how to set up a connection from an App Engine application and a Cloud SQL instance.

For information about the various options for connecting to Cloud SQL, see Connection Options for External Applications.

General information for connecting to Cloud SQL from App Engine

When you are connecting to Cloud SQL from App Engine, keep these best practices in mind:

  • App Engine has the ability to automatically create more instances when load increases. If the number of App Engine instances increases beyond what the Cloud SQL instance is sized to handle, your Cloud SQL instance will not be able to meet the demand. You can avoid this issue by setting the max_instances value for the basic_scaling element in your app.yaml file. For more information, see Scaling elements.
  • Open database connections consume resources; your application should always close connections when they are no longer being used. For App Engine standard environment, there is a hard limit on the number of connections an App Engine instance can have open to Cloud SQL. If your application requires more open connections, consider using connection pooling.

App Engine standard environment to Second Generation

Connecting to Second Generation instances from App Engine standard environment is not supported.

App Engine flexible environment to Cloud SQL

For information about connecting from App Engine flexible environment to Cloud SQL instances, see the App Engine documentation for your programming language:
Language Documentation
Python Using Cloud SQL for PostgreSQL with Python
Java Using Cloud SQL for PostgreSQL with Java
Node.js Using Cloud SQL for PostgreSQL with Node.js
Go Using Cloud SQL for PostgreSQL with Go
Ruby Using Cloud SQL for PostgreSQL with Ruby
PHP Using Cloud SQL for PostgreSQL with PHP
.NET Using Cloud SQL for PostgreSQL with .NET

Need help? For help troubleshooting the proxy, see Troubleshooting Cloud SQL Proxy connections. Or, see our Cloud SQL Support page.

What's next

Send feedback about...

Cloud SQL for PostgreSQL