© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4mo ago•
5 replies
Roger

Hyperdrive Connection Failing with Error Code 2015 - "Server returned error and closed connection"

I'm trying to set up Cloudflare Hyperdrive to connect directly to my Supabase Postgres database (bypassing the REST API to avoid Cloudflare bot detection issues), but I'm getting a connection error.

Environment:
Platform: Cloudflare Hyperdrive
Connection Method: Direct Postgres connection (port 5432)
OS: macOS
IPv4 Add-on: Enabled

What I'm trying to achieve: Connect Cloudflare Hyperdrive to my Supabase Postgres database using the direct connection string for lower latency and to bypass WAF bot detection.

Connection string format used:
postgresql://postgres:[PASSWORD]@db.[PROJECT-ID].supabase.co:5432/postgres

Error message:
Failed to connect to the provided database: Server returned error and closed connection [code: 2015]
Failed to connect to the provided database: Server returned error and closed connection [code: 2015]


What I've tried:
- Creating Hyperdrive config via Cloudflare dashboard - same error
- Creating via Wrangler CLI (npx wrangler hyperdrive create) - same error
- Verified the connection string format matches Supabase docs
- Enabled IPv4 add-on in Supabase project settings

Questions:
- Does Supabase block direct connections from Cloudflare Hyperdrive IP ranges?
- Is there a specific connection string format or authentication method required for Hyperdrive?
- Are there any firewall/security settings I need to adjust in my Supabase project settings?
- Should I be using the transaction pooler (port 6543) instead of direct connection (port 5432)?

Additional context: Following the implementation plan in Cloudflare's Supabase + Hyperdrive docs, which recommends using port 5432 since Hyperdrive provides its own transaction-mode pooling.
Screenshot_2025-10-28_at_10.40.46.png
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
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

server closed the connection unexpectedly
SupabaseSSupabase / help-and-questions
13mo ago
PrismaClientKnownRequestError: Server has closed the connection
SupabaseSSupabase / help-and-questions
3y ago
How to fix Error: P1017: Server has closed the connection. supabase
SupabaseSSupabase / help-and-questions
6mo ago
Connection to supavisor closed by server after 40 seconds
SupabaseSSupabase / help-and-questions
3y ago