Solution skill
P1001: Can't reach database server at `YOUR_HOST`:`5432`
Complete solution
Fixes Prisma error P1001 'Can't reach database server' by diagnosing which part of the connection path is wrong: host, port, pooler mode, or a server that is not actually running. Use when Prisma fails to open any connection at all. Not for authentication failures (P1000) or missing databases (P1003).
TL;DR: Check the host and port in your connection string first, then whether the database is actually listening, then whether you are pointing at a pooler port by mistake. In most reports this error is a wrong host/port or a stopped server, not a Prisma bug.
Error: P1001: Can't reach database server at `YOUR_HOST`:`5432`Steps
Verify the host and port are what you think:
node -e "const u=new URL(process.env.DATABASE_URL); console.log(u.hostname+':'+u.port)"Expected: the host and port of your real database. A stale port (for example
5433from an old setup) is the single most common cause.Check the server is listening:
nc -zv YOUR_HOST 5432Expected:
succeeded. If it fails, start the database (for exampledocker compose up -d db) and retry.If you connect through Supabase / a pooler, use the matching port and mode: session-mode pooler on port 5432 for Prisma Client, transaction-mode pooler on 6543 only with
?pgbouncer=true. Mixing them produces P1001. Expected: with the right port and mode,npx prisma db pullconnects.Re-run your app or
npx prisma validate. Expected: P1001 gone. If it becomes P1000, the host is reachable and the credentials are now the problem.
When to use
- The exact code is P1001
Can't reach database server - The failure is immediate on connect, not after a timeout (that would be P2024)
When not to use
- P1000 (authentication failed): the server is reachable, your credentials are wrong
- P1003 (database does not exist): the server is reachable, the named database is missing
Compatibility
Prisma Client 4.x through 6.x. PostgreSQL, MySQL, SQL Server.
Variant phrasing: P1001 in Docker Compose where the host is the loopback address
Inside a container, the loopback address means the container itself. Use the service name (for example db) as the host instead.
Variant phrasing: P1001 right after changing providers or regions
Connection strings go stale on migration. Re-copy the current connection string from the provider dashboard.
Why it happens
P1001 means the TCP connection never opened: wrong host, wrong port, firewall, stopped server, or a pooler/direct mismatch. Prisma never got far enough to attempt authentication, which is why the fix is always in the network path or the server state.
Edge cases
- IPv6-only hosts: some resolvers return an IPv6 address the client cannot route; try the IPv4 address explicitly.
sslmodeorsslacceptparams do not cause P1001; they surface later in the handshake.- Cloud SQL / RDS proxy endpoints change on failover; re-resolve the hostname.
Evidence
A self-hosted Coolify deployment started throwing P1001 'Can't reach database server' right after a platform update pointed the app at a new Supabase connection string. The database was up, but the app was using the direct connection details against a pooler endpoint mismatch. The fix that worked: switch the app to the pooler's session-mode connection details and redeploy; connectivity returned immediately and P1001 disappeared. Source: https://github.com/flashthefire/nexnum/commit/2d5ce557872c59fd9c698a5361d46a755171667c
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_y_0StHMX7UOS9xAV7g0upQ" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">P1001: Can't reach database server at `YOUR_HOST`:`5432` <span>— Vectle</span></a>