Skip to content

Error: P1001: Can't reach database server at MY-CONNECTION-STRING (vercel | neon | supabase | railway) #23588

Description

@Naeem-gg

Bug description

image

Hi there! I think there's a problem with prisma with serverless postgresql, I tried this on vercel postgres, supabase, railway and Neon and found this issue with all of mentioned services where it shows the same error as you can see in uploaded image. It happens very less with vercel postgres compared to others. How it gets resolved? well you need to sign in to the service dashboard and do something with databse either view some records or edit it doesn't matter you just need to interact with it and then come back to terminal and run any prisma command it will work fine. I never encountered the same with drizzle. So that's clearly something wrong with prisma and cold start of serverless postgres

How to reproduce

There's no perticular way to reproduce it but It happens with Neon the most. So create a db with Neon and continue working on it (while all the browsers where neon is logged in are closed to make sure its not running in bg) and you'll get the exact same error when you fire prisma commands db push/pull or even migrate dev

Expected behavior

No response

Prisma information

// Add your schema.prisma
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

model User {
  id        String     @id @default(cuid())
  email     String     @unique
  name      String
  password  String
  unicode   String
  createdAt DateTime   @default(now())
  updatedAt DateTime   @updatedAt
}
// Add your code using Prisma Client
import { PrismaClient } from "@prisma/client";

declare global {
  namespace NodeJS {
    interface Global {}
  }
}
interface CustomNodeJsGlobal extends NodeJS.Global {
  prisma: PrismaClient;
}
declare const global: CustomNodeJsGlobal;

const prisma = global.prisma || new PrismaClient();

if (process.env.NODE_ENV === "development") global.prisma = prisma;

export default prisma;

Environment & setup

prisma : 5.11.0
@prisma/client : 5.11.0
Computed binaryTarget : windows
Operating System : win32
Architecture : x64
Node.js : v20.9.0
Studio : 0.499.0

Prisma Version

Environment variables loaded from .env
prisma                  : 5.11.0
@prisma/client          : 5.11.0
Computed binaryTarget   : windows
Operating System        : win32
Architecture            : x64
Node.js                 : v20.9.0
Studio                  : 0.499.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions