Error: No database connection string was provided to `neon()`.

Hi.

Here is my code:

import { neon } from "@neondatabase/serverless"; import "dotenv/config"; import { drizzle } from "drizzle-orm/neon-http"; const sql = neon(process.env.NEON_DATABASE_URL!); const db = drizzle(sql); export default db;

I get the following error:

Error: No database connection string was provided to neon(). Perhaps an environment variable has not been set?

I have tried hard coding in the string, and it works. I am not sure what's going on, since if I console log the connection string, it shows up just fine in the server log. I tried the solutions here by to no avail:

helpTroubles during migrations using drizzle and a neon serverless database

Would appreciate any advice!
Was this page helpful?