EthioDeploy
DocsPricingDomainsBlogToolsChangelog

Blog/Fix deploy errors

Prisma P1001: Can't reach database server on deploy

BS
Brook SolomonPublished November 15, 2026
Share on XShare on LinkedIn
P1001

THE SHORT ANSWER

P1001 means Prisma couldn't open a network connection to the host and port in DATABASE_URL: the hostname didn't resolve, nothing was listening, or a firewall dropped the connection. On deploy it is usually one of four things: prisma migrate deploy runs in the build step, where the database isn't reachable; DATABASE_URL still says localhost, which inside a container means the container itself; the variable is missing or different at build time and at runtime; or the database only accepts connections from a private network or allowlisted IPs. Prisma 7 adds two changes to check: the CLI reads the URL from prisma.config.ts and doesn't load .env by itself, and the app connects through a driver adapter whose pool and SSL settings come from the driver.

What does P1001 mean?

Prisma's error reference gives the message as:

Can't reach database server at `{database_host}`:`{database_port}` Please make sure your database server is running at `{database_host}`:`{database_port}`.

The host and port in the message are the ones Prisma tried, so read them first. If they say localhost or 127.0.0.1 on a deployed app, that's your answer. If the host is empty, DATABASE_URL wasn't set or didn't parse.

P1001 is a network failure: Prisma never got as far as logging in. Its neighbours tell you how far it did get:

  • P1000: the server answered, but the username or password was wrong.
  • P1011: Error opening a TLS connection.
  • P1013: The provided database string is invalid.
  • P2024: connected before, but timed out waiting for a free connection in the pool.

In Prisma 7 the app connects through a driver adapter. @prisma/adapter-pg maps the driver's ENOTFOUND (the hostname didn't resolve) and ECONNREFUSED (nothing listening) to the same “database not reachable” error, so check both DNS and the port.

Quick checklist

When it failsLikely causeFix
During the build, on prisma migrate deployThe build can't reach the database's private networkRun migrations when the app starts
At runtime, host is localhostA local DATABASE_URL reached productionSet the real URL on the host, or the Compose service name
At runtime, host looks wrong or emptyVariable missing, or a password with @ or # not encodedSet it, and percent-encode the password
From your laptop or CI to a hosted databaseThe database only allows a private network or listed IPsUse its public connection string, or allow the IP
After upgrading to Prisma 7.env no longer loaded, or SSL now verifiedLoad dotenv in prisma.config.ts; fix the certificate settings

Are you running migrations during the build?

This is the one that catches people on container platforms. A build script like prisma migrate deploy && next build works on your laptop, where the database is local. On a host that builds your image in an isolated builder, the database is on a private network the build can't see, so its hostname doesn't resolve and the build stops with P1001.

Split the two jobs. prisma generate needs no database and belongs in the build. prisma migrate deploy needs the database and belongs right before the server starts:

"scripts": {
  "build": "prisma generate && next build",
  "start": "prisma migrate deploy && next start"
}

Prisma's docs also point out that migrate deploy needs the prisma package at that moment. Platforms that prune devDependencies after the build remove it, so move prisma to dependencies.

Does DATABASE_URL still say localhost?

Inside a container, localhost is the container itself, not your machine and not the database. A DATABASE_URL copied from your .env fails in production even when the database is running fine somewhere else.

With Docker Compose, connect to the database by its service name. Prisma's own Docker guide names the Postgres service postgres_db and uses:

DATABASE_URL="postgresql://postgres:prisma@postgres_db:5432/postgres?schema=public"

On a hosting platform, use the connection string the platform gives you, set as an environment variable on the service. A committed .env with a localhost URL is less dangerous than it looks: dotenv “will never modify any environment variables that have already been set”, so a real variable on the host wins. It only bites when the host variable is missing.

One more way to get a wrong host: a password with special characters. Prisma's docs say you must percent-encode them, so p@$$w0rd becomes p%40%24%24w0rd. An unencoded @ ends the password early and Prisma tries to connect to whatever follows it.

What changed in Prisma 7?

Prisma 7 moved the connection URL out of schema.prisma. The CLI reads it from prisma.config.ts, and the upgrade guide says “environment variables are not loaded by default”. A URL that only lives in .env is invisible to migrate deploy unless the config loads it:

import "dotenv/config";
import { defineConfig } from "prisma/config";

export default defineConfig({
  schema: "prisma/schema.prisma",
  migrations: { path: "prisma/migrations" },
  datasource: {
    // process.env, not env(): see below
    url: process.env.DATABASE_URL!,
  },
});

The env() helper from prisma/config throws when the variable isn't set, and every CLI command loads the config, including prisma generate, which doesn't need a database. A build without DATABASE_URL then fails with:

PrismaConfigEnvError: Cannot resolve environment variable: DATABASE_URL.

Prisma 7.0 and 7.1 print Missing required environment variable: DATABASE_URL instead. Prisma's docs suggest process.env when a command may run without the variable.

The other change is at runtime. Prisma 7 requires a driver adapter, so for Postgres you pass the URL to @prisma/adapter-pg, and the driver's own pool and SSL settings apply:

import { PrismaPg } from "@prisma/adapter-pg";
import { PrismaClient } from "./generated/prisma/client";

const adapter = new PrismaPg({
  connectionString: process.env.DATABASE_URL,
  max: 10,                       // pool size (pg default: 10)
  connectionTimeoutMillis: 5_000, // pg default 0 = wait forever
});

export const prisma = new PrismaClient({ adapter });
Prisma 6Prisma 7
CLI connection URLurl in the schema's datasourcedatasource.url in prisma.config.ts
Client connectionBuilt-in query engineDriver adapter, required
Pool sizeconnection_limit, default num_cpus * 2 + 1The driver's option, max (10) for pg
Connect timeoutconnect_timeout, 5 sconnectionTimeoutMillis, 0 (none) for pg
Engine binariesbinaryTargets on prisma-client-jsNone: prisma-client is Rust-free

The missing timeout matters for this error: Prisma 6 gives up on opening a connection after 5 seconds, while pg's default never times out, so a database behind a firewall that drops packets can look like a hung request instead of an error. If you still run Prisma 6 in Docker, binaryTargets has to include the container's platform, and Prisma's Docker guide warns against installing glibc on Alpine because Prisma downloads musl-specific engines there.

Check which major version you install. As of November 15, 2026, npm's latest tag for prisma points at a Prisma 8 release candidate, which Prisma's docs describe as a ground-up TypeScript rewrite with a different CLI. Prisma 7 stays fully supported: the docs say to install the CLI as prisma@prev and the client as @prisma/client@7.

SSL settings that break the connection

Hosted databases often require TLS, and the sslmode parameter in the URL decides what Prisma does:

  • Prisma 6 accepts prefer (the default), disable and require, and by default doesn't check the certificate (sslaccept=accept_invalid_certs).
  • Prisma 7 with pg hands the URL to node-postgres. Its pg-connection-string README says sslmode=prefer, require, verify-ca and verify-full all set ssl to true, which verifies the certificate. The upgrade guide notes that invalid certificates used to be ignored and now fail with P1010; it suggests ssl: { rejectUnauthorized: false } on PrismaPg to restore the old behaviour, or NODE_EXTRA_CA_CERTS to trust the CA properly.

Going the other way, asking for TLS from a server that doesn't offer it, node-postgres fails with The server does not support SSL connections. Use exactly the connection string your provider gives you rather than adding sslmode by habit.

What happens on EthioDeploy?

Adding a Postgres addon injects DATABASE_URL into the project:

postgres://ethiodeploy:<password>@<addon-host>:5432/ethiodeploy

The host is a private name that only resolves from your running app, on the same server. The variable reaches the build too (unless you mark it runtime only), so prisma generate and an env("DATABASE_URL") config both work there, but the database itself isn't reachable during the build. Run migrations from the Start command in Settings → Build:

npx prisma migrate deploy && npm start

Leave the internal URL as it is. The connection stays on the private network and the URL has no sslmode, which is what the addon expects. To reach the database from your own computer with psql or a GUI client, turn on external access on the Addons tab: it gives a second connection string that already ends in sslmode=require. A MySQL addon also injects DATABASE_URL, so the same steps apply with Prisma's MySQL provider.

Framework specifics are in the Next.js, NestJS and Express deploy guides.

Questions

Prisma couldn't open a network connection to the host and port in DATABASE_URL. The hostname didn't resolve, nothing was listening on the port, or a firewall dropped the connection. It happens before authentication, so the username and password haven't been checked yet.

Many hosts build your app in an isolated builder that can't reach the database's private network. Keep prisma generate in the build and run prisma migrate deploy in the start command, right before the server starts.

DATABASE_URL in production is still your local value, or it isn't set and a committed .env with a localhost URL filled the gap. Inside a container localhost is the container itself. Set the real connection string as an environment variable on the host.

Not by itself. Prisma 7's CLI reads the URL from prisma.config.ts and doesn't load .env files, so add import "dotenv/config" at the top of the config. In your app, load it the same way or set real environment variables.

Only if your database expects TLS. With Prisma 7 and the pg adapter, sslmode=require also verifies the certificate, and a server without TLS fails with "The server does not support SSL connections". Use the connection string your provider gives you.

Sources

Checked on November 15, 2026:

  • Prisma: Error reference (v7)
  • Prisma: Upgrade to Prisma ORM 7
  • Prisma: Config API (v7)
  • Prisma: Connection URLs (v7)
  • Prisma: Connection pool (v7)
  • Prisma: Deploying database changes with Prisma Migrate (v7)
  • Prisma: Docker guide (v7)
  • Prisma: Generators (v7)
  • Prisma: PostgreSQL connector (v6)
  • Prisma docs index (ORM 8 and v7 status)
  • @prisma/adapter-pg: errors.ts (7.10.1)
  • pg-connection-string README
  • node-postgres: connection.js
  • dotenv README
  • prisma on npm

Push a repo. Get a URL.

  • Database addons
  • Deploy a Next.js app
  • Deploy a NestJS app
  • Deploy an Express app
  • Environment variables
Start free

Join the EthioDeploy Telegram

Release notes as they ship, plus deploy help from the team and other developers.

Join on Telegram
BS
WRITTEN BYBrook SolomonFounder, EthioDeploy

Brook Solomon founded EthioDeploy and builds its deploy pipeline, build servers and AI coding agent. The posts here come from errors seen in real deploys on the platform.

All posts by Brook →
On this page
  • What does P1001 mean?
  • Quick checklist
  • Are you running migrations during the build?
  • Does DATABASE_URL still say localhost?
  • What changed in Prisma 7?
  • SSL settings that break the connection
  • What happens on EthioDeploy?
  • Questions
  • Sources
0% read

Keep reading

  • 53300

    Fix deploy errorsNov 17, 2026

    Postgres "too many connections" after deploy: how to fix it

    Postgres refuses new connections with "FATAL: sorry, too many clients already" (SQLSTATE 53300, too_many_connections) once every slot under max_connections is taken, and max_connections defaults to 100. After a deploy the usual cause is arithmetic: each process of your app opens its own pool (10 for node-postgres and Prisma 7, 15 for SQLAlchemy), you run several processes, and for a short time the old and the new copy of the app are both connected. Count connections in pg_stat_activity, make copies × processes × pool max fit under the limit with room to spare, release clients you check out, set idle_in_transaction_session_timeout, and put PgBouncer in front when the numbers can't fit.

  • NEXT_PUBLIC_*

    Fix deploy errorsNov 17, 2026

    NEXT_PUBLIC_ env variables undefined in production: causes and fixes

    A NEXT_PUBLIC_ variable is undefined in production when it wasn't set while next build ran. Next.js replaces every process.env.NEXT_PUBLIC_ reference with a fixed value during the build, so a variable added to the server afterwards changes nothing until you build again. The other usual causes are reading it dynamically (process.env[name] or a copy of process.env), a name without the NEXT_PUBLIC_ prefix in a Client Component, and one Docker image promoted across environments. For values that must change without a rebuild, read them on the server at request time and pass them down.

  • Invalid HTTP_HOST header

    Fix deploy errorsNov 15, 2026

    Django DisallowedHost and CSRF errors behind a proxy

    DisallowedHost means the request's Host header isn't in ALLOWED_HOSTS, so Django answers 400; add your production domain to the list. The CSRF 403 "Origin checking failed - https://... does not match any trusted origins" usually means Django thinks the request came over plain HTTP: the proxy ended HTTPS and forwarded it as HTTP, so Django expects an http:// origin and the browser sent https://. Set SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") when your proxy sets that header. Since Django 4.0, entries in CSRF_TRUSTED_ORIGINS must include the scheme, such as https://example.com.

EthioDeploy

Agentic first development and deployment, started in Ethiopia, built for developers everywhere.

Telegram community
Product
PricingAI coding agentAgent mode docsDomainsCLIFree backend hostingHosting in EthiopiaChangelog
Deploy guides
Next.jsNode.jsPythonSvelteKitTanStack StartAstroNuxtReact RouterHonoStrapiDjangoFastAPIFlaskStreamlitExpressNestJSLaravelRailsGoTelegram botDiscord botLovableBoltReplitv0Google AI StudioBase44Firebase StudioClaude Code & Cursor
Compare
vs Herokuvs Vercelvs Rendervs Railwayvs Fly.iovs Netlifyvs KoyebHeroku alternativesVercel alternativesNetlify alternativesRender alternativesRailway alternativesFly.io alternativesReplit alternativesPythonAnywhere alternativesDigitalOcean App Platform alternativesGlitch alternatives
Resources
DocsBlogFree toolsAboutSupportContactllms.txt
© 2026 EthioDeployPay by card in USD or bank transfer in ETBTermsPrivacy