Uptimy
All Articles
Infrastructure··7 min read

Neon Postgres Monitoring: Uptime Checks Without Breaking Scale to Zero

A database check every minute keeps Neon awake and can use up the Free plan's compute. How to monitor a Neon app, its connections and its cron jobs.

✅

Short answer

  • Mind the check interval. Neon suspends a compute after 5 minutes without activity. A check that queries the database every minute keeps it awake all month, which on the Free plan uses up the 100 CU-hours in about 17 days.
  • Check through your app, and pick the frequency on purpose: often on a paid plan, every 15 to 30 minutes on Free, or a route that doesn't touch the database.
  • Neon doesn't alert on downtime. Its only documented notifications are spending emails. Errors, connection limits and outages need an external check and heartbeats for jobs.

Neon's serverless Postgres is a common choice behind Vercel and Next.js apps: it branches like Git and costs nothing while idle. The second part is what makes monitoring it different from monitoring a regular database.

Scale to zero changes how you check

According to Neon's scale-to-zero docs, a compute that has been inactive for 5 minutes is suspended, and the next query wakes it, typically within a few hundred milliseconds. On the Free plan the 5 minutes are fixed; Launch can turn scale to zero off; Scale can set anything from 1 minute to always on.

A monitoring check that runs a query counts as activity. Check every minute and the compute never reaches 5 idle minutes, so it never suspends. On paid plans that's a cost decision. On the Free plan it's a hard limit: each project gets 100 CU-hours a month, which Neon equates to a 0.25 CU compute running for 400 hours, and a month is about 730. Per Neon's plans page, when the hours run out the compute is suspended until the next billing period, and connections fail. The monitoring would have caused the outage it then reports.

Choose what to check, and how often

  • Paid plan, production app: check a route that runs a real query, every minute or two. The compute stays warm, which your users probably want anyway.
  • Free plan: check the same route every 15 to 30 minutes. Each check wakes the compute for about 5 minutes, so a 30-minute interval keeps it awake roughly a sixth of the time.
  • Free plan, compute must sleep: check a route that doesn't touch the database for frequent uptime, and rely on heartbeats from real jobs to prove the database still works.
app/api/health/route.ts
import { neon } from "@neondatabase/serverless";

const sql = neon(process.env.DATABASE_URL!);

export async function GET() {
  try {
    await sql`select 1`;
    return Response.json({ db: "ok" });
  } catch {
    return Response.json({ db: "error" }, { status: 503 });
  }
}

Check it with status 200 and the keyword "db":"ok", from more than one region, with a timeout of several seconds so a cold start isn't mistaken for an outage. When it fails, the Neon status page tells you whether it's Neon or you.

Connection limits

Serverless functions open many short connections, and Neon caps them. On a direct connection, max_connections depends on compute size: 112 at 0.25 CU, 450 at 1 CU. Neon's connection pooling (PgBouncer in transaction mode) takes up to 10,000 client connections; you use it by adding -pooler to the endpoint ID in the hostname.

Two errors are worth recognizing in your logs: remaining connection slots are reserved on a direct connection, and a query_wait_timeout after two minutes waiting for the pooler. Both look like an outage to users. The health route above sees them, as long as it connects the same way your app does.

What Neon shows you

The monitoring page charts CPU, RAM, connections, pooler connections, database size, deadlocks and cache hit rate, kept for 1 day on Free, 3 on Launch and 14 on Scale. Datadog and OpenTelemetry export are on the Scale plan. The only built-in notifications Neon documents are spending alerts by email at 80% and 100% of a monthly budget, on paid plans. One more detail: computes only send metrics while they're running, so gaps during scale to zero are normal.

Scheduled jobs

Neon supports pg_cron, with a catch the pg_cron docs spell out: it only runs while the compute is active, so it suits an always-on compute. A suspended compute misses its schedule silently.

Most Neon apps run jobs elsewhere: Vercel cron, GitHub Actions, a worker. Wherever they run, end each one with a heartbeat ping on success, and give the heartbeat the same schedule:

app/api/cron/cleanup/route.ts
import { neon } from "@neondatabase/serverless";

const sql = neon(process.env.DATABASE_URL!);

export async function GET() {
  await sql`delete from sessions where expires_at < now()`;

  // Only reached if the query above succeeded.
  await fetch(process.env.UPTIMY_HEARTBEAT_URL!);
  return Response.json({ ok: true });
}

A missed run, a failed query or a suspended compute all end the same way: no ping, one alert.

Where the alerts go

A failing health route means users are affected; a missed cleanup can wait. Alert routing sends each to the right place, and a public check can update your status page when it fails.

📌Key Takeaways

  • 1Neon suspends a compute after 5 minutes idle; every query wakes it
  • 2A database check every minute keeps the compute on and can use up the Free plan's 100 CU-hours in about 17 days
  • 3On Free, check every 15 to 30 minutes, or check a route that doesn't touch the database
  • 4Use the -pooler hostname; direct connections are capped by compute size
  • 5Neon only documents spending notifications; downtime and errors need an external check
  • 6pg_cron only runs while the compute is active; give every job a heartbeat

23:00 · goodnight

All systems operational

Stop wondering if production is okay.

Tonight, if something breaks, you will know first — with the context to fix it and a status page that keeps customers informed. And if nothing breaks, you get to sleep.

Free plan available · No credit card required · Cancel anytime