Repository navigation
Description
Bug description
🐛 Bug Report — $connect() succeeds even when DB is offline in Prisma v7 using @prisma/adapter-pg
Summary
After upgrading to Prisma v7 and switching to the @prisma/adapter-pg adapter, calling $connect() no longer throws an error when the PostgreSQL server is offline.
Instead, it logs a successful connection, which makes startup and health checks unreliable.
How to Reproduce
-
Stop PostgreSQL service
-
Start a NestJS or Node.js application that calls
await prisma.$connect() -
Observe: Prisma reports a successful connection even though the DB is down
Expected Behavior
$connect() should fail immediately with a connection error if the database is unreachable — matching the behavior in Prisma < v7.
Actual Behavior
-
$connect()completes successfully -
Shows
"Prisma connected"log message -
No exception is thrown until the first query is executed later
Terminal Output Screenshot
NestJS log showing “Prisma connected” while DB is offline
PostgreSQL Service Status Screenshot
Postgres service stopped / disabled
Code Example
import { Injectable, Logger, OnModuleInit } from '@nestjs/common'; import { PrismaPg } from '@prisma/adapter-pg'; import { PrismaClient } from 'prisma/generated/prisma/client';@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
private readonly logger = new Logger(PrismaService.name);constructor() {
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL!,
});
super({ adapter });
}
async onModuleInit() {
try {
await this.$connect();
this.logger.log('Prisma connected');
} catch (e) {
this.logger.error('Prisma connection error', e);
}
}
}
Environment
| Component | Version |
|---|---|
| Prisma | 7.x.x |
| Adapter | @prisma/adapter-pg |
| DB | PostgreSQL |
| Runtime | NestJS (also reproducible in plain Node) |
| OS | (windows) |
| Node.js | (20.19.5) |
Additional Context
This appears to be a regression introduced with the new PG adapter + connection-less architecture. It causes production systems to falsely assume database health, breaking readiness checks.
Severity
🚨 Critical: Data loss, app crash, security issue
Reproduction
Expected vs. Actual Behavior
🐛 Bug Report — $connect() succeeds even when DB is offline in Prisma v7 using @prisma/adapter-pg
Summary
After upgrading to Prisma v7 and switching to the @prisma/adapter-pg adapter, calling $connect() no longer throws an error when the PostgreSQL server is offline.
Instead, it logs a successful connection, which makes startup and health checks unreliable.
How to Reproduce
-
Stop PostgreSQL service
-
Start a NestJS or Node.js application that calls
await prisma.$connect() -
Observe: Prisma reports a successful connection even though the DB is down
Expected Behavior
$connect() should fail immediately with a connection error if the database is unreachable — matching the behavior in Prisma < v7.
Actual Behavior
-
$connect()completes successfully -
Shows
"Prisma connected"log message -
No exception is thrown until the first query is executed later
Terminal Output Screenshot
NestJS log showing “Prisma connected” while DB is offline
PostgreSQL Service Status Screenshot
Postgres service stopped / disabled
Code Example
import { Injectable, Logger, OnModuleInit } from '@nestjs/common'; import { PrismaPg } from '@prisma/adapter-pg'; import { PrismaClient } from 'prisma/generated/prisma/client';@Injectable()
export class PrismaService extends PrismaClient implements OnModuleInit {
private readonly logger = new Logger(PrismaService.name);constructor() {
const adapter = new PrismaPg({
connectionString: process.env.DATABASE_URL!,
});
super({ adapter });
}
async onModuleInit() {
try {
await this.$connect();
this.logger.log('Prisma connected');
} catch (e) {
this.logger.error('Prisma connection error', e);
}
}
}
Environment
| Component | Version |
|---|---|
| Prisma | 7.x.x |
| Adapter | @prisma/adapter-pg |
| DB | PostgreSQL |
| Runtime | NestJS (also reproducible in plain Node) |
| OS | (windows) |
| Node.js | (20.19.5) |


Activity
fix(adapter-pg): validate database connection during connect
fix(adapter-pg): validate database connection during connec
fix(adapter-pg): validate database connection during connect
fix(adapter-pg): validate database connection during connect