Services
Postgres
A Postgres 16 database per project, with a built-in explorer, SQL editor and nightly backups.
Deploy
Click Deploy on the Postgres card. CloudHike.dev creates a database named app and a non-superuser role that owns it, then shows the connection string with Reveal, Copy, Reset password and Delete.
| Plan | Where it runs | Size |
|---|---|---|
| Free | A shared server. Your project gets its own p_… database and a role that can open only that database, with at most 30 connections and a 30 second statement timeout. | 500 MB, 128 MB RAM |
| Pro | A container of its own, at the Standard size until you resize it | No size limit (billed per GB above 1 GB), 256 MB to 4 GB RAM |
After upgrading, a Pro user can move a shared database to its own container from the Postgres card. Writes pause while it is copied, every table's row count is checked against the original, and the old copy is kept closed for 7 days before it is dropped.
Sizes and resizing
On Pro, each database runs at a compute size and is charged for that size per hour while it runs. A paused database is not charged for compute. New databases start at Standard.
| Size | Memory | CPU | Connections | Per hour | About per month |
|---|---|---|---|---|---|
| Micro | 256 MB | 0.25 | 50 | $0.0125 | $9.13 |
| Standard | 256 MB | 1 | 50 | $0.014 | $10.22 |
| Small | 512 MB | 1 | 100 | $0.026 | $18.98 |
| Medium | 1 GB | 1 | 200 | $0.050 | $36.50 |
| Large | 2 GB | 2 | 400 | $0.100 | $73.00 |
| XL | 4 GB | 2 | 800 | $0.196 | $143.08 |
To change it, open Resize on the Postgres card, or the Configuration tab of Open database, pick a size and click Resize. The database restarts at the new size on the same disk and port, so your data, DATABASE_URL and DIRECT_URL stay the same. Apps lose their connections for a few seconds and reconnect on their next query. Memory, shared_buffers (a quarter of the memory) and the connection limit follow the size, and the connection pooler is resized with it.
- A resize needs a day of the new size in credits.
- Picking the size the database already has shows Apply settings: it restarts the database with the current settings for its size. Databases created before the connection limit grew with memory run with 20 connections until you do this.
- If the database does not start at the new size, it goes back to the old one and the card shows why.
- Free databases are on the shared server and have no size. Upgrade to Pro and move the database to its own container first.
Connect
The connection string is in DATABASE_URL. When TLS is on, it ends in ?sslmode=require and the public port accepts only encrypted connections.
| Variable | Use it for |
|---|---|
DATABASE_URL | Your app's queries. It goes through a connection pooler (PgBouncer), so many app connections share a few real ones: up to 200 on the Free plan, and on Pro 20 for every connection the database allows (1,000 on Standard, more on larger sizes). |
DIRECT_URL | Only on pooled databases: migrations (drizzle-kit push, Prisma's directUrl), pg_dump, LISTEN/NOTIFY, session-level SET and advisory locks. It is limited to 30 connections on Free; on Pro, the database's own limit (47 on Standard), half of which the pooler may use. |
The pooler lends a real connection for one transaction at a time. Prepared statements work. Anything that has to last longer than a transaction on one connection needs DIRECT_URL.
psql "$DATABASE_URL"import { Pool } from "pg";
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
const { rows } = await pool.query("select * from todos where done = $1", [false]);import { drizzle } from "drizzle-orm/node-postgres";
import { Pool } from "pg";
// One pool per process, kept across dev hot reloads.
const globalForDb = globalThis as unknown as { pool?: Pool };
const pool = globalForDb.pool ?? new Pool({ connectionString: process.env.DATABASE_URL, max: 5 });
if (process.env.NODE_ENV !== "production") globalForDb.pool = pool;
export const db = drizzle(pool);import os, psycopg
with psycopg.connect(os.environ["DATABASE_URL"]) as conn:
print(conn.execute("select version()").fetchone())Open connections count against the plan. Use one pool per server process and keep it small, especially on serverless platforms where each invocation can open its own connection. In development, keep the pool on globalThis as above: otherwise every hot reload opens a new pool and the old one stays connected.
- Connections idle for 5 minutes are closed by the server. Pools open a new one on their next query.
- Once a database uses half its connection limit, the usage check (every 5 minutes) closes connections that have been idle for over a minute, such as those a dev server leaves behind on hot reload. Running queries are never touched.
- If you see
too many connections for role, click Close idle connections on any tab of Open database to free the limit right away. - The Usage page shows each database's connections and marks one Maxed out for a day after it hit its limit.
Database explorer
Click Open database on a ready Postgres card to browse and query without installing anything.
| Tab | What it does |
|---|---|
| Data | Pick a schema, search the table list, browse 25 to 250 rows per page, sort, search across a row, and click a row to see or copy it as JSON. |
| SQL Editor | Run SQL with results in a grid, save snippets, and keep a per-project history in your browser. |
| Stats | Database size, connections, cache hit ratio, uptime, and each table's size, rows and index use. |
| Configuration | The key Postgres settings, read-only. |
| Extensions | See what is installed and enable trusted extensions such as pgcrypto, citext and hstore. |
| Backups | List, take, download and restore backups. |
| Connect | Host, port, database and user, with the password on request. |
Everything is read-only until you switch off Read-only in the SQL editor. Each query has a 10 second statement timeout and a 3 second lock timeout. With writes allowed, a script runs in one transaction that commits only if every statement succeeds, and statements like DROP, DELETE and UPDATE ask for confirmation.
Backups
A nightly job at 02:00 runs pg_dump for every running database and stores the dump in the project's storage bucket under _backups/postgres/. Without a Storage service, it uses the platform's backup bucket instead.
- Retention is set on the Backups tab: up to 7 days on Free and 30 on Pro. The newest backup is always kept.
- Take a backup at any time with the Backup now button.
- Download a backup through a short-lived signed link.
- Restore first takes a safety backup, loads the dump into a new database next to the live one, and swaps them only after it fully loads. A failed restore leaves your database untouched.
- Backups stop when storage would pass 98% of the Free plan's storage limit, or on Pro of the platform's safety ceiling.
Limits, sleeping and size
- A Free database over its size limit gets a warning from the usage check. After 3 days over, it becomes read-only until you free space or upgrade. Pro databases have no size limit and are never paused for size: disk above 1 GB is billed at $0.40 per GB-month. A Pro database still on the shared server keeps the Free limit until you move it to its own container.
- Free databases with no connections for 6 hours are stopped. Click Wake on the card to start one again.
- Click Pause on the card to stop a database yourself. Your data is kept, and compute is not charged while it is paused. Click Resume to start it again.
- Reset password creates a new password and updates
DATABASE_URL. Apps still using the old password are disconnected until you update them.
Use with AI
Ask an agent to connect your app to the project's database, create tables and write queries.
- 1
Open a terminal in your app's folder and start Claude Code.
claude - 2
Paste the prompt below and press Enter. Approve the file edits and commands it asks about.
- 3
Optional: save a short note about CloudHike.dev in CLAUDE.md so every session knows about it.
Read https://cloudhike.dev/docs/md/postgres, then connect this app to my CloudHike.dev Postgres database. - DATABASE_URL is in my env file (if not, follow https://cloudhike.dev/prompt.md with my project id and access token to download it). - Use the ORM or driver this app already uses. If it has none, use node-postgres or the standard driver for this language. - Create the tables this app needs with migrations. Do not drop or rewrite existing tables. - Open at most a small connection pool (3 to 5 connections), created once per process and kept on globalThis so dev hot reloads reuse it. - Never print or commit the connection string.
Replace the placeholders in <angle brackets> before sending. Always review what the agent changes.
