DEV Community

Abdullah Bashir
Abdullah Bashir

Posted on

1 1

Prisma db push or pull stuck?

Fix for Prisma connection stuck.

When working with Prisma and Supabase DB, I got an issue with the Prisma CLI getting stuck during prisma db push and prisma db pull. I eventually for to know that the issue often arises when using a Supabase connection string with the pooled connection (port 6543).

For example, running npx prisma db push took 9 minutes here and still failed:

Slow execution

The Fix

To resolve this, I needed to switch to a direct connection string using port 5432 instead. I tried changing it on the Supabase dashboard and then saw this:

Supabase Dashboard

What you need to change:

# Old Pooled Connection
DATABASE_URL="postgresql://...@db.supabase.co:6543/db"
DIRECT_URL="postgresql://...@db.supabase.co:6543/db"

# New Direct Connection
DATABASE_URL="postgresql://...@db.supabase.co:6543/db"
DIRECT_URL="postgresql://...@db.supabase.co:5432/db"
Enter fullscreen mode Exit fullscreen mode
// What your Prisma Datasource initialiser should look like
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider  = "db"
  url       = env("DATABASE_URL")
  directUrl = env("DIRECT_URL")
}
Enter fullscreen mode Exit fullscreen mode

Now, let's see how it runs:

Fast Execution

Happy Hacking!


PS: For more details, check out the GitHub discussion.

API Trace View

Struggling with slow API calls?

Dan Mindru walks through how he used Sentry's new Trace View feature to shave off 22.3 seconds from an API call.

Get a practical walkthrough of how to identify bottlenecks, split tasks into multiple parallel tasks, identify slow AI model calls, and more.

Read more →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs