© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•7mo ago•
2 replies
tom5088

RLS Connection Error with Next.js + Prisma (service_role)

After enabling RLS on my tables, my Next.js backend API routes using Prisma Client are failing with PrismaClientInitializationError: Can't reach database server.

This error occurs even when the Prisma Client is configured to use the service_role key and the direct database connection string (port 5432).

The most confusing part is that a CLI command like npx prisma migrate dev connects successfully, but the exact same Prisma Client fails within the Next.js application runtime.

My understanding is that the service_role key should bypass RLS entirely. Could you please help me understand why enabling RLS would cause a connection-level failure for a privileged client, and why the CLI and the app runtime behave differently?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Service role not bypassing RLS
SupabaseSSupabase / help-and-questions
3y ago
Next.js SSR RLS
SupabaseSSupabase / help-and-questions
13mo ago
RLS with Prisma
SupabaseSSupabase / help-and-questions
5mo ago
Next JS Service Client
SupabaseSSupabase / help-and-questions
13mo ago