9

How to change the postgresql.conf parameter "max_connections" on Google Cloud SQL?

When I exceed 100 connections I get the error: "FATAL: remaining connection slots are reserved for non-replication superuser connections"

1
  • You're usually better off putting a connection pooler like pgbouncer in front. Surprised they don't do that automatically. Commented Jun 1, 2017 at 4:29

2 Answers 2

9

Normally you would do it via CloudSQL flags API (or UI): https://cloud.google.com/sql/docs/postgres/flags

However, max_connections is not a parameter we currently support. We (Postgres team in CloudSQL) are aware that low max_connections is a problem for some (many?) applications and will address issue in one of the next releases.

Please follow issue 37271935 on our public issue tracker for updates.

Sign up to request clarification or add additional context in comments.

Comments

1

Years later, it seems like it's supported now.

For the Terraform gang, you can update the parameter this way:

resource "google_sql_database_instance" "main" {
  name             = "main-instance"
  database_version = "POSTGRES_14"
  region           = "us-central1"

  settings {
    tier = "db-f1-micro"

    database_flags {
      name  = "max_connections"
      value = 100
    }
  }
}

Note that at the time of writing the db-f1-micro default max_connections is 25, refs https://cloud.google.com/sql/docs/postgres/flags#postgres-m

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.