Skip to content

Network restrictions

Direct database connections go through the connection pooler (PgBouncer). Two per-project settings control who may connect:

  • Enforce SSL: connections that do not use TLS are rejected.
  • Allowed IP addresses: a list of IPv4 / IPv6 addresses or CIDR ranges. When the list is empty, any address may connect. When it has entries, every other address is rejected.

Both apply only to clients outside the Base network. The Data API, Auth, Storage, Realtime and every other Base service reach the database over the internal network and are never restricted, so a wrong list cannot take your project offline. You can always still reach the database from the SQL editor.

Open Database → Settings (owners only), turn on Enforce SSL and/or list the allowed addresses, one per line, then Save settings. The pooler applies the change within a few seconds. Existing connections stay open until they close; only new connections are checked.

Terminal window
curl -X PATCH "$BASE_URL/v1/projects/my-project/config/db" \
-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" \
-d '{"ssl_enforced": true, "allowed_cidrs": ["203.0.113.0/24", "2001:db8::/32"]}'
  • A bare address becomes /32 (IPv4) or /128 (IPv6). Entries are normalised and de-duplicated.
  • At most 50 entries. An invalid entry returns 400 validation_failed and nothing is saved.
  • GET /v1/projects/{ref}/config/db returns ssl_enforced, allowed_cidrs and enforcement_available.

Use sslmode=require (or verify-full with the CA of your certificate):

postgres://USER:PASSWORD@db.example.com:5432/PROJECT_DB?sslmode=require

Hosted Base projects already have a certificate. On a self-hosted instance see Self-hosting: without a certificate configured, Enforce SSL makes the database unreachable from outside the Base network.