© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•8mo ago•
1 reply
𝙩𝙠

Recurrent PostgreSQL Connection Issues – ConnectionDoesNotExistError using asyncpg

Hello, im experiencing recurring connection issues with my PostgreSQL database hosted on Supabase. My application (a Discord bot written in Python) is encountering the following error during database operations:
asyncpg.exceptions.ConnectionDoesNotExistError: connection was closed in the middle of operation
asyncpg.exceptions.ConnectionDoesNotExistError: connection was closed in the middle of operation


Technical Details:
- Library: asyncpg (Python)
- Operation Type: Simple SQL query execution
- Frequency: Multiple occurrences in the past 6 hours (previously ran for over 4 months without issues)

Error Log:
File "/application/.local/lib/python3.13/site-packages/asyncpg/connection.py", line 352, in execute asyncpg.exceptions.ConnectionDoesNotExistError: connection was closed in the middle of operation
File "/application/.local/lib/python3.13/site-packages/asyncpg/connection.py", line 352, in execute asyncpg.exceptions.ConnectionDoesNotExistError: connection was closed in the middle of operation


Application Context:
- The Discord bot has been running 24/7 for over 4 months on a server
- Connections are created on demand for each operation
- I am not currently using a connection pool

Questions:
- Is there a timeout for idle connections on Supabase?
- Are there any recommended configurations for long-running applications?
- Would you recommend using connection pooling for this kind of application?

I appreciate any guidance on best practices to restore stable connections.
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

Connection Issues
SupabaseSSupabase / help-and-questions
5mo ago
PostgreSQL pool connection from express
SupabaseSSupabase / help-and-questions
4y ago
Connection issues today
SupabaseSSupabase / help-and-questions
4w ago
issues with connection
SupabaseSSupabase / help-and-questions
13mo ago