I had to do the reverse of the changes mentioned above, as Supabase now configure and provide a IPv6 hostname for DATABASE_URL. Adding an environment variable with ECTO_IPV6=true resolved the problem and my app now connects successfully to the Postgres database.
I had this exact problem, tried your solution adding it as secret with key ECTO_IPV6 and value true. Tried with ssl=true commented out and with it left in.
Apologies, I didn’t include all of the changes which I made so this may be useful for you to resolve your issue. You may also need to make some changes to config/runtime.exs if you’ve previously run mix phx.gen.release.
I’m deploying my application as a Docker container so I added the following environment variables:
This combined with the extra configuration in config/runtime.exs was enough to enable my application to connect with the Supabase database host over IPv6.
Ah! @hagenek – I missed the “pooler” part of the hostname for your database. AFAIK, Supabase provide 2 hostnames in separate environment variables:
DATABASE_URL offers a direct IPv6 connection to your database. Use this URL from your Fly.io applications.
DATABASE_POOLER_URL runs connections through a connection pooler. Currently, the connection pooler runs outside of Fly.io and may introduce connection latency. Use this URL to test connection pooling behavior, or to connect from locations that don’t support IPv6, like many household ISPs.
From the look of it, you need to use a IPv6 connection string in DATABASE_URL. It appears like you’re trying to connect to a IPv4 address over IPv6 so I’d start there with your investigation.
I’m hitting this issue from a fly deployed phoenix app that uses fly ext supabase integration - As far as I can tell, I have the correct settings for ipv6, and am using the DATABASE_URL printed out by fly.
Would modifying queue_target be a possible culprit?
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []
config :byline_by, MyApp.Repo,
pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
socket_options: maybe_ipv6,
url: database_url
queue_target: 1000 # could this be the issue?
If I navigate to supabase, I see that that connection is still configured to use ipv4