Skip to main content
Live. This area is documented as current, user-reliable behavior.

Goal

Connect through the right endpoint and publish native database access for external clients when needed.

Prerequisites

  • An existing database

Workflow

1
Read the stable hostname, port, database name, username, and TLS details from the database page.
2
Choose the private or public network endpoint, then the direct or pooled role and protocol offered for that database.
3
For external access, choose Direct connection or StackShift tunnel and set a client IP policy.
4
Wait for the public policy to become active, download the CA, and verify the hostname with a native client.
5
Smoke-test through the same stable endpoint after restore, promotion, or rollback.

Stable connection details are authoritative

Use only the connection information displayed for the logical database. Do not infer a container name, node IP, physical generation, or hidden candidate address. Import candidates never expose credentials and never inherit public access.
  • Treat the stable hostname as the application-facing identity.
  • Use the required TLS mode and CA information shown by the product.
  • Retrieve credentials on demand and avoid copying them into tickets, logs, or documentation.
  • Use application bindings where available instead of manually reconstructing connection strings.

Variables added to your app

When you connect a database to an app, StackShift adds its connection details as environment variables. A variable you set yourself always wins and is never overwritten when you connect. Rotating the main password and moving to Dedicated are different: they update any variable that holds the old password or points at the old database.
  • Postgres, MySQL and MariaDB: DATABASE_URL plus DB_HOST, DB_PORT, DB_NAME/DB_DATABASE, DB_USER/DB_USERNAME, DB_PASSWORD and DB_TYPE.
  • Redis and Valkey: REDIS_URL, REDIS_HOST, REDIS_PORT and REDIS_PASSWORD. Adding Redis or Valkey to an app that already has a SQL database leaves DATABASE_URL alone.
  • MongoDB: MONGODB_URI, with MONGO_URL and MONGODB_URL as aliases, and MONGODB_CA_CERT for the CA file path. Adding MongoDB to an app that already has a SQL database leaves DATABASE_URL alone.
  • OpenSearch: OPENSEARCH_URL, OPENSEARCH_USERNAME, OPENSEARCH_PASSWORD, and OPENSEARCH_CA_CERT for the CA file path, plus ELASTICSEARCH_URL with the same address for Elasticsearch 7.x clients. Adding OpenSearch to an app that already has a SQL database leaves DATABASE_URL alone.
  • Laravel apps also get DB_CONNECTION, plus MYSQL_ATTR_SSL_CA (MySQL and MariaDB) or DB_SSLMODE and PGSSLROOTCERT (Postgres), so the default config/database.php connects over verified TLS.
  • Java and Spring Boot apps also get SPRING_DATASOURCE_URL, SPRING_DATASOURCE_USERNAME and SPRING_DATASOURCE_PASSWORD, plus the same values as JDBC_DATABASE_*. For MySQL with TLS, the MySQL Java driver needs a truststore, so build the JDBC URL from DB_* and the CA at MYSQL_SSL_CA.
  • .NET apps also get ConnectionStrings__DefaultConnection, an Npgsql or MySqlConnector connection string with certificate checks on.

Rotate the main password

Change the main password when it may have leaked or when someone with access leaves. Open the database, go to Settings, then General, and choose Rotate password next to Main password. The confirmation lists the projects connected to the database. StackShift sets a new password on the database and updates every variable in your projects whose value contains the old main password, either as the exact value or inside a connection address. That covers connected projects, any other project that holds the password, and WordPress, Ghost and stack services. Each updated project is redeployed. The page shows each step and the status of every app while it runs, and you can leave the page and come back. When it finishes, the database page shows the new password.
  • The old password stops working once your apps have the new one. On MySQL, Redis and Valkey it stays valid until the updated apps have redeployed. On PostgreSQL, MariaDB, MongoDB and ClickHouse it changes at once, and connections that are already open stay up.
  • Anything outside StackShift that signs in with the main password, such as a laptop client, a CI job or a server elsewhere, has to be updated by hand with the new password.
  • Database users you added in Users and roles keep their passwords. Reset those separately.
  • If an app fails to redeploy, the old password is still retired and the rotation shows as failed with the names of the apps. Fix the app and redeploy it; its variables already have the new password.
  • Only one rotation or other change can run on a database at a time. If one is already running, wait for it to finish and try again.
  • Redis and Valkey databases without a password can’t be rotated, because adding a password would break the apps that connect without one.

Connection pooling

Connection pooling is available where the database and plan support it. When enabled, the database exposes a pooler host/port for application traffic with many short-lived connections. The direct endpoint remains necessary for clients that depend on session-level behavior.
  • Transaction mode: a connection is assigned for the duration of a transaction. This suits most applications.
  • Statement mode: the most aggressive mode, assigning per statement — only for workloads that tolerate it.
  • Migrations, administrative clients, session variables, prepared statements, and similar features may require direct access.

Shared connections and sleep

Where Sleep when idle is switched on, a Starter database that nobody is using goes to sleep. Shared connections (pooled) stay open while it sleeps: the first query waits for the database to wake and then runs, and your app never sees a disconnect. Direct connections are closed when the database goes to sleep, so give your driver’s pool a health check and an idle timeout below your sleep timer. On Dedicated databases, Shared connections close at sleep too. Branches use the Shared connections address by default, because branches sleep after 5 minutes. See Sleep when idle for what a client sees while the database wakes and for settings for each driver.

Private and public access

Public access does not replace the private endpoint. Direct uses a public listener on the assigned database node. StackShift tunnel carries native TCP traffic through db-tunnel.stackshift.cloud to the private database endpoint. The client needs no tunnel software and the node needs no public database listener. The edge enforces restricted CIDRs using the original client IP; database TLS passes through to the database. Direct access does not open a port range on the node. Restricted sources, expired policies, and revoked endpoints stay blocked. Direct Open to internet policies must pass a control-plane TCP connection check for every published endpoint before activation is recorded. A timeout reports public_endpoint_unreachable and follows normal retries. This check proves TCP reachability, not client authentication or TLS configuration. Restricted policies retain their allowlist and existing readiness evidence; the worker is not automatically added to permitted sources. Tunnel access keeps its existing edge verification. Tunnel access is available for qualified hosted and customer-added nodes. Supported engines are PostgreSQL, MySQL, MariaDB, MongoDB, Redis, Valkey, and ClickHouse. Customer-added nodes need a current tunnel-ready agent heartbeat. If a connected node is waiting for the relay update, use Update agent on its Nodes page, wait for a fresh heartbeat, then reopen Credentials. Credentials shows a specific reason when the database or node is still ineligible.
  • Restricted by IP: supply client CIDRs and an expiry; renew before expiry.
  • Open to internet: explicitly acknowledge exposure; managed renewal keeps the policy active until revoked.
  • Transport is fixed for a policy. Revoke it and wait for withdrawal before creating a policy with a different transport.
  • A tunnel never falls back to direct. Revocation withdraws the public listener and sessions.

Enable a tunnel in the dashboard

  • Open the database, select Credentials, then the Public tab. The Create database form offers the same network and transport choices.
  • Choose StackShift tunnel, then Restricted by IP with your client CIDR and expiry, or Open to internet with the required acknowledgement.
  • Wait for Active. Switch Credentials to Public and select the protocol endpoint. ClickHouse can have separate native and HTTP ports.
  • Download the CA. Use the displayed hostname, assigned port, connection string, and TLS server name; do not substitute the engine default port.

Public-access API

Use the same suffix for project databases at /api/v1/projects/{projectID}/databases/{databaseID} or standalone databases at /api/v1/databases/{databaseID}. Creating, revoking and retrying public access need a signed-in browser (the database page in the dashboard) or a full-access API token; CLI device-login tokens and agent tokens get 403 browser_session_required. GET /public-access works for every token. Creation returns a policy before reconciliation finishes. Poll /public-access until active_policy.status is active, then fetch /credentials for the verified public endpoint. Set a unique Idempotency-Key for each create request. Revoke takes an optional body {"policy_id":"<uuid>"} to name one policy from /public-access; without it the newest policy is revoked. A 404 means that policy is already revoked or expired. A 409 means a newer policy is still being applied, so revoke the newer one instead.
Restricted tunnel access
Open access and revoke

Connect a native client

Use the exact public connection string from Credentials with the downloaded CA and full hostname verification. Native psql, mysql, mongosh, redis-cli (or valkey-cli), and ClickHouse clients connect to the assigned edge port like any other TCP database endpoint. The edge does not receive database passwords or terminate database TLS. Keep credentials and CA files out of source control.
PostgreSQL example

What transfer promotion preserves

  • Private and public hostname and port.
  • Database name, username/password identity, and credential fingerprint.
  • CA and TLS policy.
  • Allowlist or anywhere public-access mode.
  • Proxy and firewall policy.

Expected result

A native client connects to the active endpoint with the displayed credentials and verified database TLS.

Common failures

  • Using a stale copied connection string instead of reopening current database details.
  • Sending migration or session-dependent traffic through an incompatible pooler mode.
  • Pointing an application at a physical candidate or node address instead of the stable hostname.
  • Assuming public access is required when the application can use the private endpoint.

Create a database

Create a hosted or connected-node database with private, direct public, or StackShift tunnel access.

Import and export a database

Move complete PostgreSQL or MySQL databases as portable SQL with resumable uploads, private candidates, structural validation, explicit promotion, and 24-hour rollback.

Back up and restore a database

Use durable recovery storage correctly and understand why backups are independent from portable SQL transfers.

Database troubleshooting

Diagnose provisioning, tunnel access, deletion, backup, transfer, and recovery failures.

Sleep when idle

A database nobody is using goes to sleep and wakes on the next connection. Its address, password and data stay the same.

Branches

A copy of your database you can change freely. It has its own address and password, and sleeps when nobody’s using it.