Your DATABASE_URL is the Postgres connection string Neon builds for you. Open your project in the Neon Console, click Connect on the Project Dashboard, and copy the connection string from the Connect to your database modal. Paste it into your framework's .env file as DATABASE_URL and you're set.
Get the URL
- Sign in to the Neon Console and select your project.
- On the Project Dashboard, click Connect.
- Pick a Branch, Compute, Database, and Role.
- Copy the connection string. Keep Connection pooling on unless you specifically need a direct connection.
A Neon DATABASE_URL looks like:
postgresql://alex:AbC123dEf@ep-cool-darkness-a1b2c3d4-pooler.us-east-2.aws.neon.tech/dbname?sslmode=require&channel_binding=requireBoth sslmode=require and channel_binding=require are part of the URL because Neon requires TLS. Don't strip them. See Connect from any app for what each segment means.
Use it in your app
Save it as DATABASE_URL in your .env:
DATABASE_URL="postgresql://alex:AbC123dEf@ep-cool-darkness-a1b2c3d4-pooler.us-east-2.aws.neon.tech/dbname?sslmode=require&channel_binding=require"Then read it from your code:
import { Client } from 'pg';
const client = new Client({ connectionString: process.env.DATABASE_URL });
await client.connect();Common conventions in framework integrations:
- Vercel: When you connect Neon through the Vercel integration, Neon writes
DATABASE_URL(pooled) andDATABASE_URL_UNPOOLED(direct) to your Vercel project's env vars. See the Vercel managed integration. - Prisma: Set
url = env("DATABASE_URL")(pooled) anddirectUrl = env("DIRECT_URL")(direct) inschema.prisma. See Connect from Prisma. - Drizzle: A single
DATABASE_URL(pooled) is usually enough. See Connect from Drizzle.
Treat DATABASE_URL as a secret
The URL contains the role's password in plain text. Never commit it to a repo, log it, or paste it in a chat. If it ever leaks, reset the role's password right away. The old URL stops working as soon as the reset completes.

Find your stack's guide for Next.js, Prisma, Drizzle, Django, FastAPI, and more.








