# Can't connect to supabase db using transaction mode

**URL:** <https://community.fly.io/t/cant-connect-to-supabase-db-using-transaction-mode/22141>\
**Category:** General\
**Tags:** postgres, machines, login-only\
**Created:** [October 4, 2024, 4:04pm UTC](https://community.fly.io/t/cant-connect-to-supabase-db-using-transaction-mode/22141 "2024-10-04T16:04:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andres](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/andres/32/15364_2.png) [@Andres](https://community.fly.io/u/Andres)\
**Post date:** [October 4, 2024, 4:04pm UTC](https://community.fly.io/t/cant-connect-to-supabase-db-using-transaction-mode/22141/1 "2024-10-04T16:04:52Z")

</div>

ConnectorError(ConnectorError { user\_facing\_error: None, kind: QueryError(PostgresError { code: “42P05”, message: “prepared statement "s1" already exists”, severity: “ERROR”, detail: None, column: None, hint: None }), transient: false })

I’m trying to connect to a supabase database in transaction mode with port 6543 but I’m getting that error…

I don’t know if I have to add any special option to fly to work with this?

# fly.toml file generated for sharely-develop on 2023-08-23T17:34:02-05:00

app = “sharely-develop”  
kill\_signal = “SIGINT”  
kill\_timeout = 5  
processes =

[env]  
PORT = “8080”

[[services]]  
internal\_port = 8080  
processes = [“app”]  
protocol = “tcp”  
[services.concurrency]  
hard\_limit = 25  
soft\_limit = 20  
type = “connections”

[[services.ports]]  
force\_https = true  
handlers = [“http”]  
port = 80

[[services.ports]]  
handlers = [“tls”, “http”]  
port = 443

---

<div class="post-metadata">

**Author:** ![ktosiek](https://sea1.discourse-cdn.com/fly1/user_avatar/community.fly.io/ktosiek/32/38162_2.png) [@ktosiek](https://community.fly.io/u/ktosiek)\
**Post date:** [October 6, 2024, 10:27am UTC](https://community.fly.io/t/cant-connect-to-supabase-db-using-transaction-mode/22141/2 "2024-10-06T10:27:09Z")

</div>

The error mentions prepared statements. Prepared statements are created per connection, not per transaction: you’ll need to disable them in your app to use transaction mode pooling.

References:

- Supabase docs for Transaction mode: [Connecting to your database | Supabase Docs](https://supabase.com/docs/guides/database/connecting-to-postgres#transaction-mode-port-6543)  
“Transaction mode does not support prepared statements. To avoid errors, turn off prepared statements for your specific connection library.”
- PostgreSQL docs for “PREPARE”: [PostgreSQL: Documentation: 17: PREPARE](https://www.postgresql.org/docs/current/sql-prepare.html)  
“Prepared statements only last for the duration of the current database session.”

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/fly1/original/3X/6/e/6e8955d00cb218e186ebbe3a6ab06fefdce15290.svg) [@system](https://community.fly.io/u/system)\
**Post date:** [October 13, 2024, 10:27am UTC](https://community.fly.io/t/cant-connect-to-supabase-db-using-transaction-mode/22141/3 "2024-10-13T10:27:35Z")

</div>

Closed on October 13, 2024, 10:27am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
