What this covers
Your managed database runs PostgreSQL 17. Apps reach it at db.cmcloudhosting.com on port 5432, through a connection pooler in transaction mode, with TLS required. The pooler lets many app connections share a few real database connections. That is why a small pool is enough, and why a few features tied to a single connection behave differently. Every database is backed up each night.
Before you start
Create the database from your app's service page and copy DATABASE_URL from the Connection tab.
How to do it
- Pass the connection details from the Connection tab to your app through an environment variable, exactly as shown. Keep sslmode=require: the endpoint refuses unencrypted connections with FATAL: SSL required.
- Leave external access on. Apps connect through the same endpoint as your own database tools, so turning it off cuts your app off too.
- Keep the connection pool small: 5 to 10 connections per app is plenty. Behind the pooler, a bigger pool holds slots without adding concurrency.
- Turn off cached server-side prepared statements, which do not survive transaction pooling: prepareThreshold=0 for JDBC, ?pgbouncer=true for Prisma, prepare_threshold=None for psycopg 3. Left on, they cause errors such as 'prepared statement S_1 does not exist' under load rather than on the first request.
- Don't rely on session state. SET, temporary tables, advisory locks held across transactions and LISTEN/NOTIFY belong to one server connection, which the pooler gives to another client after each transaction. Keep that kind of work inside a single transaction.
- Let a migration tool own the schema: Django migrations, Laravel migrations, Flyway, Prisma Migrate or Alembic. The database starts empty. Django and Laravel migrations run on every deploy; for other runtimes, run them from your startup code or Start command.
- Make migrations backwards compatible. During a deploy the old version keeps serving until the new one is healthy, so add a column before code uses it, and drop it a release after code stops using it.
- Index the columns you filter and sort on, and check slow queries with EXPLAIN ANALYZE from psql or your database tool.
- Watch your size. The service page warns at 80% of your plan's storage. At 100% the database becomes read-only until you free space or upgrade.
- We dump every database each night and keep 7 daily, 4 weekly and 2 monthly copies. To restore one, contact support with the date. For a copy of your own, run pg_dump with the details from the Connection tab.
Starter code and references
What our team checks
Support can check that your database is reachable, restore a nightly backup for a date you name, and look at storage use with you. Support does not tune your queries or change your schema.
Next step
Open your app's Database tab, check that the connection string has sslmode=require, and set your pool size.