Drizzle-kit incorrectly defaulting to @neondatabase/serverless driver

Hello, initially set up drizzle.config.ts and did a drizzle-kit generate and migrate and that worked. Now when I attempt to run a generate and migrate, the migrate fails, saying it can't open a websocket to the neon database. I am hosting pg in docker locally, my database url is such: DATABASE_URL=postgres://<user>:<password>@localhost:5432/drizzle-db
Using '@neondatabase/serverless' driver for database querying
Warning '@neondatabase/serverless' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket
Using '@neondatabase/serverless' driver for database querying
Warning '@neondatabase/serverless' can only connect to remote Neon/Vercel Postgres/Supabase instances through a websocket
My Drizzle config is such:
import { loadEnvConfig } from "@next/env";
import { defineConfig } from "drizzle-kit";
loadEnvConfig(process.cwd());

export default defineConfig({
out: "./drizzle",
schema: "./db/schema.ts",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});
import { loadEnvConfig } from "@next/env";
import { defineConfig } from "drizzle-kit";
loadEnvConfig(process.cwd());

export default defineConfig({
out: "./drizzle",
schema: "./db/schema.ts",
dialect: "postgresql",
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});
(using nextjs - if i console log the process.env.DATABASE_URL, it is correct according to the database url i pasted above) Drizzle-orm works just fine in the actual app, connecting the database . I'm not sure why it is defaulting now to neon in drizzle-kit migrate? Maybe my package got updated and that is just a default setting now? Am i missing something in the config??
1 Reply
vanHessler
vanHesslerOP3d ago
I think i solved it.. I checked the version of drizzle-kit that was being used (in npx drizzle-kit migrate) and it was v0.27.1 for some reason. I installed locally in the project and its now using 0.31.0 which is working. 🤷‍♂️ not sure why it was using the old version?? Ok i found the actual issue. I had accidentally installed the drizzle-kit package and neon-serverless package at a higher directory (the parent directory) of my codebase, and it was defaulting to that for some reason since i hadn't specified drizzle-kit in my repo as a package.

Did you find this page helpful?