Skip to content

Supabase and Prisma errorPrisma P1001: “Can’t reach database server” on Supabase

Migrations or the deployed app fail with P1001: Can’t reach database server, though it worked on your laptop. The usual reason is the connection string: Supabase’s direct connection is IPv6 only unless you buy the IPv4 add-on, and many hosts and CI runners only speak IPv4. Here’s which string to use where, in Supabase’s words, or hand it over at a fixed price.

Short answer

Use a pooler connection string instead of the direct db.[project-ref].supabase.co one. For a serverless app on Vercel or similar, set DATABASE_URL to the transaction pooler (port 6543) with ?pgbouncer=true, and DIRECT_URL to the session pooler (port 5432, which works over IPv4) for migrations, and point Prisma’s migrations at DIRECT_URL (directUrl in schema.prisma, or the datasource url in prisma.config.ts on Prisma 7). Copy both from the Connect button in the Supabase dashboard rather than typing them, then redeploy.

Why Prisma can’t connect

  1. 01

    The host can’t reach the IPv6 direct connection

    “If your network is IPv4-only and you don't have the add-on, use session mode instead.” Supabase, Connect to your database

    The direct connection works from networks with IPv6 and fails silently from IPv4-only ones, which looks exactly like P1001. Switch to the shared pooler, which is reachable over IPv4.

  2. 02

    Serverless functions need the transaction pooler

    “Make sure to append "pgbouncer=true" to the end of the string, which turns off prepared statements.” Supabase, Prisma

    Vercel and other serverless hosts open many short connections. Point DATABASE_URL at the transaction pooler and turn off prepared statements, or you trade this error for prepared statement errors.

  3. 03

    The connection string is wrong

    “Malformed connection string: The connection string used by Prisma is incorrect or incomplete.” Supabase, Prisma troubleshooting

    A password with special characters that isn’t URL-encoded, a pooler user without the .project-ref suffix, or a hand-built pooler host all fail the same way. Copy the string from the dashboard.

  4. 04

    The database is overloaded or paused

    “Database overload: The database server is under heavy load, causing Prisma to struggle to connect.” Supabase, Prisma troubleshooting

    If the string is right and it still times out, check the database’s CPU and memory in the dashboard, and whether a Free plan project was paused.

Checked against the vendor’s docs on : Supabase docs: Prisma troubleshooting; Supabase docs: Prisma; Supabase docs: Connect to your database.

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

Related: Supabase too many connections · Supabase project paused · Supabase migration failed on db push · Prisma prepared statement already exists

Questions

More on this error

Why does it work on my laptop?

Your home network likely has IPv6, so the direct connection works. Many hosting platforms and CI runners only have IPv4, which the direct connection doesn’t accept without the IPv4 add-on.

Should I buy the IPv4 add-on instead?

Only if you need a direct connection, for example for a long-running server that needs features the pooler lacks. For most Prisma apps, the shared pooler is the fix.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; we reply by email, usually within one business day.