Neon error
No database connection string was provided to neon(). Perhaps an environment variable has not been set?
"No database connection string was provided to neon(). Perhaps an environment variable has not been set?" means the value passed to neon() was undefined or empty, almost always process.env.DATABASE_URL on a deployment that has no variable of that name. In Vercel, add DATABASE_URL for the environment that fails (Production or Preview), then redeploy, because a change applies only to new deployments. From @neondatabase/serverless 1.2.0 the same mistake reads "Wrong URL scheme or missing user, host or database in connection parameters" and shows up on the first query, not when neon() is called. Reproduced with @neondatabase/serverless 1.1.0 and 1.2.0 on 2026-10-31.
Why does neon() say "Wrong URL scheme or missing user, host or database in connection parameters"?
The package changed in 1.2.0 (2026-10-01). Its changelog says neon() now accepts connection parameters such as user, password, host and database as well as a connection string, and the check moved with it. In 1.1.0, 1.0.2 and 0.10.4, neon(undefined) threw the long message at once, at the line where the client is created. In 1.2.0 that call returns, and the first query throws a NeonDbError. An empty string gives a third text in 1.2.0, "Database connection string provided to neon() is not a valid URL (connection string: )". The real messages wrap neon() in backticks in the older versions; they are left out here.
Drizzle hides the text one level down. With drizzle-orm 0.45.4 and the neon-http driver, the error you see is "Failed query: select 1", and the driver message is in the error cause, so print error.cause in your logs.
// 1.1.0 and earlier: thrown by neon(undefined)
Error: No database connection string was provided to neon(). Perhaps an environment variable has not been set?
// 1.2.0: thrown by the first query
NeonDbError: Wrong URL scheme or missing user, host or database in connection parametersWhy does DATABASE_URL work on my machine but not on Vercel?
Vercel applies a variable to the environments you pick for it (Production, Preview, Development), and a change reaches only deployments made after it. Your local .env or .env.local file is not uploaded. The vercel env pull command writes the Development variables into a local .env file, so a value that lives only in that file never reaches Production.
With Neon's Vercel integration, DATABASE_URL holds the pooled connection string and DATABASE_URL_UNPOOLED the direct one. If you pasted the string by hand under another name, such as NEON_DATABASE_URL, the code must read that exact name. Preview branch variables from the integration are injected at deployment time and are not shown in Vercel's variable settings.
How do I get a clearer error when the Neon variable is missing?
Check the variable yourself before you call neon(). The error then names the variable, and it reads the same in every driver version.
import { neon } from "@neondatabase/serverless";
const url = process.env.DATABASE_URL;
if (!url) throw new Error("DATABASE_URL is not set in this environment");
export const sql = neon(url);Checklist
How to fix it, then check the fix
- 01Find every place the driver is created and the variable it reads:
grep -rnE "neon[(]|DATABASE_URL" src app lib --include=*.ts --include=*.tsx --include=*.js - 02In Vercel, open the project, then Settings, then Environment Variables, and confirm a variable with exactly that name exists.
- 03Check the environments ticked for it. A variable set only for Production does not reach Preview deployments, and the other way round.
- 04Redeploy. Vercel applies a changed variable only to new deployments, so an old deployment keeps failing.
- 05Check the fix: open the route that failed and confirm the error is gone from the function logs. To see the Development values locally:
vercel env pull
Related
Related guides
Sources
Official docs behind this checklist
Browse all launch guides · Read resources · How to make and check your next change
FAQ
FAQ for builders before launch
Does neon() read DATABASE_URL on its own?
Not in the version tested. With @neondatabase/serverless 1.1.0, neon() with no argument threw this error even though DATABASE_URL was set in the environment. Neon's docs pass the value in: neon(process.env.DATABASE_URL).
Why does Drizzle show "Failed query" and not this message?
Drizzle wraps the driver error. With drizzle-orm 0.45.4 and @neondatabase/serverless 1.2.0, the "Wrong URL scheme or missing user, host or database in connection parameters" text sat in the error cause, not the message.
Why does the error appear only on a preview deployment?
Vercel assigns each variable to Production, Preview or Development. A DATABASE_URL set only for Production is missing from Preview deployments, and Neon's integration injects its preview branch variables at deployment time instead of showing them in the variable settings.