#Can't reach database server at `db.prisma.io:5432`

11 messages · Page 1 of 1 (latest)

cloud totem
#

Hello everyone, I having an issue connecting with connection string provided by console.prisma.io in prisma v7.

    const db = config.getOrThrow(ENV_KEYS.DATABASE_URL);
    const adapter = new PrismaPg({
      connectionString: db,
    });
    super({ adapter });
  }

my env is as follows:

DATABASE_URL=postgres://[email protected]:5432/postgres?sslmode=require

When I try to run prisma migrate dev I get the following error:

Loaded Prisma config from prisma.config.ts.

Prisma schema loaded from prisma/schema.prisma.
Datasource "db": PostgreSQL database "postgres", schema "public" at "db.prisma.io:5432"

Error: P1001: Can't reach database server at `db.prisma.io:5432`

Please make sure your database server is running at `db.prisma.io:5432`.
cobalt windBOT
#

Skipping coffee for instant knowledge! Let's brew that AI answer now.

cobalt windBOT
# cobalt wind Skipping coffee for instant knowledge! Let's brew that AI answer now.

This looks like a connectivity issue to Prisma Postgres, not a config-shape problem. The knowledge sources show the same P1001 error in multiple contexts, but they don’t give a Prisma-7‑specific fix for db.prisma.io. I can only suggest what’s explicitly documented or already used for similar errors.

  1. Verify the URL format
    Your URL matches the documented Prisma Postgres direct‑TCP format:
    postgres://USER:[email protected]:5432/?sslmode=require [Connection URLs].
    Make sure:

    • It uses postgres:// (not postgresql:// if the console gave postgres://).
    • There is a / before the query string (as in the docs example).
    • No stray characters or line breaks in .env.
  2. Check basic network reachability
    The P1001 message is the generic “can’t reach server” error used for all backends (Supabase, local Postgres, Prisma Postgres, etc.). [P1001 docker; Connection loss]
    From the same machine where you run prisma migrate dev, test:

    • psql with the same URL.
    • ping db.prisma.io or nc db.prisma.io 5432 (if available) to confirm the port is reachable.
  3. Try increasing connect timeout
    For slow or flaky connections, adding connect_timeout to the URL can avoid P1001 timeouts:
    ?sslmode=require&connect_timeout=300 [Timeout hint; Timeout workaround].

  4. Confirm credentials from the Console
    Ensure you copied the exact connection string from the Prisma Console for direct TCP, not an Accelerate URL, and that the credentials haven’t been rotated. [Prisma Postgres example].

If all of the above checks out and psql can connect but `prisma m

cobalt windBOT
cobalt windBOT
scarlet glacier
#

Hey!

Can you share with me the email associated with your prisma account? I would like to check the logs and see what's causing this.

I'll also try to reproduce this

cloud totem
cloud totem
#

To give more context this error

when I use accelarateUrl it works:

DATABASE_URL=prisma+postgres://accelerate.prisma-data.net/?api_key=eyJhb...

PrismaService:

  constructor(private readonly config: ConfigService) {
    const db = config.getOrThrow(ENV_KEYS.DATABASE_URL);
    super({ accelerateUrl: db });
  }

When I use my local db instance it works:

DATABASE_URL=postgresql://postgres:1234@localhost:5432/app

PrismaService:

  constructor(private readonly config: ConfigService) {
    const db = config.getOrThrow(ENV_KEYS.DATABASE_URL);
    const adapter = new PrismaPg({
      connectionString: db,
    });
    super({ adapter });
  }

But when I use the TCP connection string from prisma.io it does not work:

DATABASE_URL=postgressql://[email protected]:5432/postgres?sslmode=require

PrismaService:

  constructor(private readonly config: ConfigService) {
    const db = config.getOrThrow(ENV_KEYS.DATABASE_URL);
    const adapter = new PrismaPg({
      connectionString: db,
    });
    super({ adapter });
  }

I think the issue is coming from prisma.

scarlet glacier
#

Hmm, I tried reproducing this but was unable to do so 🤔

#

Could you try spinning up a temporary postgres database by running npx create-db and try if you get the same issue with the new database?

nocturne ibex
#

where are you running this, Vercel? If you're running it somewhere with access to the instance, are you able to establish a TCP connection manually? nc -vz db.prisma.io 5432