Skip to content

MySQL pool timeout using adapter (rust free engine) #28612

Closed

Description

@FelixBaum

Bug description

I'm trying to upgrade prisma from version 6.17.0 to 7.0.0.
I'm using MySQL with the PrismaMariaDb driver adapter

const databaseUrl = process.env.DATABASE_URL;

const adapter = new PrismaMariaDb(databaseUrl);

const prisma = new PrismaClient({ adapter });

I'm getting following error while trying to get data from the database:

pool timeout: failed to retrieve a connection from pool after 10001ms (pool connections: active=0 idle=0 limit=10)

Severity

🚨 Critical: Data loss, app crash, security issue

Reproduction

Install the mariadb adapter, npx prisma generate, try a simple query, and timeout

Expected vs. Actual Behavior

No timeout error is thrown and I can query data from my database.

Frequency

Consistently reproducible

Does this occur in development or production?

Both development and production

Is this a regression?

n/a

Workaround

n/a

Prisma Schema & Queries

generator client {
  provider   = "prisma-client"
  output     = "../prisma/client"
  engineType = "client"
}

datasource db {
  provider = "mysql"
}

Prisma Config

import dotenv from '@dotenvx/dotenvx';
import { defineConfig, env } from "@prisma/config";

dotenv.config();

export default defineConfig({
    datasource: {
        url: env('DATABASE_URL'),
    },
});

Logs & Debug Info

No response

Environment & Setup

  • Database: MySQL
  • Node.js version: v20.19.5

Prisma Version

7.0.0

Activity

  1. added
    kind/bug
    on Nov 21, 2025
  2. brenc commented on Nov 21, 2025

    @brenc

    Hit this myself. This is very confusing. It looks like you have to set the connection info w/ the adapter now:

    const adapter = new PrismaMariaDb({
      connectionLimit: 5,
      database: 'db',
      host: 'db',
      password: env.DB_PASSWORD,
      user: env.DB_USER,
    });
    const prisma = new PrismaClient({ adapter });

    The reason you're getting the error you're getting is because Prisma defaults to localhost. It's not using DATABASE_URL at all from the looks of it.

  3. louiecodes commented on Nov 23, 2025

    @louiecodes

    I just migrated from Prisma v5 to v7 and also have same problem. I'm using @prisma/adapter-mariadb.

  4. FelixBaum commented on Nov 24, 2025

    @FelixBaum
    Author

    Just tried to set the connection info myself:

    const adapter = new PrismaMariaDb({
        connectionLimit: 10,
        host: process.env.DB_HOST,
        port: process.env.DB_PORT ? parseInt(process.env.DB_PORT) : undefined,
        user: process.env.DB_USER,
        password: process.env.DB_PASSWORD,
        database: process.env.DB_NAME,
    });
    
    const prisma = new PrismaClient({ adapter });

    But unfortunately I'm getting the same error..

  5. louiecodes commented on Nov 24, 2025

    @louiecodes

    Just tried to set the connection info myself:
    But unfortunately I'm getting the same error..

    I already tried same and still getting error.

    I just downgraded Prisma to v6 with its respective configuration and works fine. Will continue using v6 as for now.

  6. Kareszrk commented on Nov 24, 2025

    @Kareszrk

    I wanted to switch instantly once I saw 7.0 is out, and I am consistently unable to connect to any database using the current 7 version. I receive a 'pool timeout error'. All Prisma operations (like schema creation) work fine, but the connection itself fails. I literally cannot access any data, but the typescript types and stuff works perfectly. I've ruled out environment issues by testing a blank project and by observing no incoming connections on the DB server. Downgrading to v6 immediately fixed the problem. This appears to be a bug in the latest release that needs fixing. Hope they will fix it soon. Until then I have to keep using v6.

  7. Kareszrk commented on Nov 24, 2025

    @Kareszrk

    I would like to point out the fact that this error also occures on node v22 and node v24 not just on v20 as mentioned in this issue.

  8. treedots-kavan commented on Nov 25, 2025

    @treedots-kavan

    I also faced this issue

  9. rivatove commented on Nov 25, 2025

    @rivatove

    This error implies the connection with your DB fails to be estabilished. You need to debug the exact cause using the underlying mariadb library.

    Common issues:

    1. If using single parameter url constructor, you need to change mysql:// to mariadb:// in the connection string.
    2. If using any extra parameters in the query string of the url (e.g. sslcert), you need to appropriately translate them into the object constructor.
  10. vpmedia commented on Nov 25, 2025

    @vpmedia

    If I remember correctly for me it was that I had to set ssl: false, allowPublicKeyRetrieval: true explicitly in the adapter config. Of course this is only true if you are not using SSL for the MySQL connection.

    Also for debugging you can try to attach a logger instance to the adapter config like this:

    logger: {
        error: (error) => logger.error('PrismaAdapterError', error),
    },
    

    Also you can try:

    import Debug from '@prisma/debug';   // requires `pnpm install @prisma/debug` I think
    Debug.enable('prisma:driver-adapter:mariadb');
    
    

    ref:
    https://mariadb.com/docs/connectors/mariadb-connector-nodejs/node-js-connection-options

  11. jcubic commented on Nov 25, 2025

    @jcubic

    I have the same error. I've created a new Next.js project to reproduce #28627 now I can't even get to the stage when error appear.

    Here is my project with a repro (for above):

    https://github.com/jcubic/prisma-7-bug

    Note that I can connect to MySQL using mysql command.

  12. brenc commented on Nov 25, 2025

    @brenc

    So it looks like you can do:

    const adapter = new PrismaMariaDb({
      connectionLimit: 5,
      database: 'db',
      host: 'db',
      password: env.DB_PASSWORD,
      user: env.DB_USER,
    });
    const prisma = new PrismaClient({ adapter });

    Or:

    const adapter = new PrismaMariaDb(env.DATABASE_URL);
    const prisma = new PrismaClient({ adapter });

    I think what tripped me up was thinking the adapter should be using DATABASE_URL automatically. Also, I'm using mysql://... and it appears to work just fine this way with MariaDB too.

    Sometimes the issue is that env vars should be getting set, but are not. I find it best to validate my env with Zod on start, so that if any of my expected env vars aren't getting set, my apps will crash right away.

  13. HamzaOutmassint commented on Nov 25, 2025

    @HamzaOutmassint

    I've hit a brick wall with this error—I’ve tried every possible solution under the sun, but nothing seems to make a difference. It's incredibly frustrating!

  14. ayoub-khemissi commented on Nov 25, 2025

    @ayoub-khemissi

    This solution worked for me on MySQL 8.0 with the mariadb adapter. Seems weird because I thought you only had to put this in your .env file:

    DATABASE_URL="mysql://user:password@localhost:3306/database"

    Now I have:

    DB_CONNECTION_LIMIT="5"
    DB_HOST="localhost"
    DB_PORT="3306"
    DB_DATABASE="database"
    DB_USER="user"
    DB_PASSWORD="password"

    And this inside my prisma.service.ts file:

    import { Injectable } from '@nestjs/common';
    import { PrismaClient } from '@prisma/client';
    import { PrismaMariaDb } from '@prisma/adapter-mariadb';
    
    @Injectable()
    export class PrismaService extends PrismaClient {
      constructor() {
        const adapter = new PrismaMariaDb({
          connectionLimit: Number(process.env.DB_CONNECTION_LIMIT),
          database: process.env.DB_DATABASE,
          host: process.env.DB_HOST,
          password: process.env.DB_PASSWORD,
          user: process.env.DB_USER,
        });
        super({ adapter });
      }
    }
  15. jcubic commented on Nov 25, 2025

    @jcubic

    I use new URL() to parser process.env.DATABASE_URL

    It seems that I parsed /database in my case, and this throw an error.

    So using this works fine:

    const getPrisma = () => {
      const adapter = new PrismaMariaDb(process.env.DATABASE_URL as string);
      return new PrismaClient({ adapter });
    };
  16. 19 remaining items

  17. alireza-malek commented on Dec 12, 2025

    @alireza-malek
    Contributor

    The core issue here is diagnostics: the mariadb driver attaches the real connection failure as a nested cause, but Prisma only surfaced the outer pool timeout message. As a result, users couldn’t see whether the problem was SSL/TLS, connectivity, or auth, which made these failures hard to diagnose:

    pool timeout: failed to retrieve a connection from pool after 10000ms (pool connections: active=0 idle=0 limit=5)

    However, the driver also includes a cause with the real reason, for example:

    • "RSA public key is not available client side. Either set option `cachingRsaPublicKey` to indicate public key path, or allow public key retrieval with option `allowPublicKeyRetrieval`" (in this case set allowPublicKeyRetrieval: true as @vpmedia mentioned)

    or

    • "Connection timeout: failed to create socket after 1003ms" (increasing connectTimeout may help)

    I opened a PR that passes the cause through so the underlying reason shows up directly in the Prisma error payload.

  18. added a commit that references this issue on Dec 15, 2025
    7e120ed
  19. added a commit that references this issue on Dec 16, 2025
    fdcbc53
  20. Pouet-- commented on Dec 18, 2025

    @Pouet--

    The code from @yc-w-cn helped me to know what was the error :

    const adapter = new PrismaMariaDb({
      host: process.env.DATABASE_HOST,
      port: Number(process.env.DATABASE_PORT) || 3306,
      user: process.env.DATABASE_USER,
      password: process.env.DATABASE_PASSWORD,
      database: process.env.DATABASE_NAME,
      connectionLimit: 5,
      //allowPublicKeyRetrieval: true,
      logger: {
        network: (info) => {
          console.log('PrismaAdapterNetwork', info);
        },
        query: (info) => {
          console.log('PrismaAdapterQuery', info);
        },
        error: (error) => {
          console.error('PrismaAdapterError', error);
        },
        warning: (info) => {
          console.warn('PrismaAdapterWarning', info);
        },
      }
    });

    My password is URI-encoded in my .env file. I removed the encoding and typed it as asual, and it worked.
    So now I have DATABASE_URL, which contains all connection info, with encoded password, and DATABASE_PASSWORD, which is not encoded...

  21. pjhi commented on Dec 18, 2025

    @pjhi

    Current Prisma Client Setup:

    • Basically same with the documentation

    Issue persists for the following versions:

    • @prisma/client - ^7.1.0
    • @prisma/adapter-mariadb - ^7.1.0
    • prisma - ^7.1.0

    Currently using Windows 11.

    Additional Notes:

    • Everything works completely fine after I ran npx prisma studio. Even when I stopped the studio, it still works. The error only occurs when I restart my device completely and ran the client again. Not sure if this applies to everyone here but this is what I've noticed when running the Prisma Studio

    Exactly the same here under macos

  22. malith-senevirathna commented on Dec 22, 2025

    @malith-senevirathna
    const adapter = new PrismaMariaDb({
        host: config.database.host ?? '',
        user: config.database.user ?? '',
        password: config.database.password ?? '',
        database: config.database.name ?? '',
        connectionLimit: 5,
        allowPublicKeyRetrieval: config.nodeEnv === 'development',
        ssl: config.nodeEnv === 'production',
    });
    

    These configs fixed the problem. Thanks @alireza-malek.

  23. rtussing commented on Jan 13, 2026

    @rtussing

    I ran into a similar issue as described in the initial bug description. I used the following code to print the error messages, and adding allowPublicKeyRetrieval: true, fixed the issue for me.

    const adapter = new PrismaMariaDb({
        host: dbUrl.hostname,
        port: dbUrl.port,
        user: dbUrl.username,
        password: dbUrl.password,
        database: dbUrl.pathname.slice(1), // Remove leading '/'
        connectionLimit: 10,
        // logger: {
        //     network: (info) => {
        //         console.log('PrismaAdapterNetwork', info);
        //     },
        //     query: (info) => {
        //         console.log('PrismaAdapterQuery', info);
        //     },
        //     error: (error) => {
        //         console.error('PrismaAdapterError', error);
        //     },
        //     warning: (info) => {
        //         console.warn('PrismaAdapterWarning', info);
        //     },
        // },
        allowPublicKeyRetrieval: true,
    });
  24. dmnq2000 commented on Jan 23, 2026

    @dmnq2000

    I'm using [email protected] with [email protected] on [email protected]. Just add import 'dotenv/config'; then it works.

    // prisma.service.ts
    import 'dotenv/config';
    import { Injectable } from '@nestjs/common';
    import { PrismaClient } from '../generated/prisma/client';
    import { PrismaMariaDb } from '@prisma/adapter-mariadb';
    
    @Injectable()
    export class PrismaService extends PrismaClient {
      constructor() {
        const adapter = new PrismaMariaDb({
          host: process.env.DATABASE_HOST,
          port: Number(process.env.DATABASE_PORT!),
          user: process.env.DATABASE_USER,
          password: process.env.DATABASE_PASSWORD,
          database: process.env.DATABASE_NAME,
          connectionLimit: 10,
          allowPublicKeyRetrieval: true,
        });
        super({ adapter });
      }
    }
  25. Kareszrk commented on Jan 23, 2026

    @Kareszrk

    For me it says no matter what I do, that ESM is not supported. But when I modify my NestJS's config from CommonJS to anything else it breaks, and when I lookup what's up I always come to a documentation that states that NestJS can only be used if it's configured as CommonJS. I use NestJS version 10, and NodeJS version 22.

  26. Kareszrk commented on Jan 23, 2026

    @Kareszrk

    Or, if I follow prisma's documentation and include in the schema file that I want it to render CJS it just does not do that. It ignores that totally, and the ESM issue remains.

  27. HrOice commented on Feb 10, 2026

    @HrOice

    I found problems in process.env when I print it with "console.log(process.env)"
    shows like:

    DATABASE_HOST: '"192.168.5.10"',
    DATABASE_PASSWORD: '"123456"',
    and command env shows:
    DATABASE_HOST="192.168.5.10"
    DATABASE_PASSWORD="123456"

    then I export them without double quotes, it works...

  28. Vaibhav-Vanjani commented on Mar 6, 2026

    @Vaibhav-Vanjani

    This works:❤️

    Update Prisma to latest version and fix MariaDB connection issues,
    After updating Prisma CLI, @prisma/client, and the PrismaMariaDb adapter to the latest matching versions, I added the following connection options to resolve connection and SSL issues when connecting to MariaDB:

    allowPublicKeyRetrieval: true,
    ssl: {
    rejectUnauthorized: false
    },
    connectTimeout: 10000

  29. added a commit that references this issue on Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug/1-unconfirmedkind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions