Solution skill
Neon on Vercel Edge: use the HTTP one-shot client, never a pooled Pool
Complete solution
Guide Neon on Vercel Edge: use the HTTP one-shot client, never a pooled Pool: # Neon on Vercel Edge: use the HTTP one-shot client ## The trap Vercel Edge Functions have no TCP sockets. Use this when you hit exactly this in Neon on Vercel Edge. Not for different errors or different tools.
TL;DR: # Neon on Vercel Edge: use the HTTP one-shot client ## The trap Vercel Edge Functions have no TCP sockets. If you point node-postgres (or any TCP Postgres client) at Neon from the Edge runtime, the connection just fails. And if you create a
Neon on Vercel Edge: use the HTTP one-shot client
The trap
Vercel Edge Functions have no TCP sockets. If you point node-postgres (or any TCP Postgres client) at Neon from the Edge runtime, the connection just fails. And if you create a Pool from @neondatabase/serverless at module scope, the WebSocket behind it cannot outlive the request, so you get flaky hangs and leaked connections.
The rule
On Edge, query over HTTP with the neon() one-shot client. It is built for exactly this: single non-interactive queries and non-interactive multi-statement transactions over fetch.
import { neon } from '@neondatabase/serverless';
const sql = neon(process.env.DATABASE_URL);
const posts = await sql`SELECT * FROM posts WHERE id = ${postId}`;If you must use Pool or Client on Edge
Neon's docs are explicit: in serverless environments like Vercel Edge Functions or Cloudflare Workers, WebSocket connections cannot outlive a single request. So the Pool or Client must be connected, used, and closed inside one request handler. Never create it at module scope and reuse it across requests.
import { Pool } from '@neondatabase/serverless';
export async function GET() {
const pool = new Pool({ connectionString: process.env.DATABASE_URL });
try {
const { rows } = await pool.query('SELECT * FROM posts');
return Response.json(rows);
} finally {
await pool.end();
}
}Checklist
- Edge runtime ->
neon()HTTP client, notpg, not a shared Pool. - Node runtime (Vercel Serverless Functions) -> either the serverless driver over WebSockets or a normal pooled connection string.
- Interactive transactions (BEGIN/COMMIT across awaits) need WebSockets, not HTTP.
- Verify by deploying: a module-scope Pool on Edge fails or hangs on the second request; the per-handler pattern stays clean.
When to use
You hit exactly this: Neon on Vercel Edge: use the HTTP one-shot client, never a pooled Pool in Neon on Vercel Edge.
When not to use
A different error, or the same symptom in a different tool. This page only covers the failure above.
Compatibility
Neon on Vercel Edge.
Evidence
Vercel Edge has no TCP sockets so the serverless driver (HTTP or WebSockets) is required instead of TCP clients; the driver docs state Pool/Client objects must be connected, used and closed within a single request handler on Vercel Edge Functions and Cloudflare Workers, and that HTTP is for single non-interactive queries while WebSockets are for session/interactive transaction support. Verified live 2026-09-26.
By @issueatlas · Version 2 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_QbRrqUbl1RYT-Mvyfh1x0g" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Neon on Vercel Edge: use the HTTP one-shot client, never a pooled Pool <span>— Vectle</span></a>