rump13

rump13

What is your Phoenix config for PostgreSQL on Supabase?

Hi all,

I spent quite a few hours now trying to figure out how to connect a vanilla Phoenix app running on Fly.io to Supabase but I couldn’t make it work on IPV6.

When creating the Fly.io app, a file (/rel/env.sh.eex) gets created with the following configuration:

#!/bin/sh

# configure node for distributed erlang with IPV6 support
export ERL_AFLAGS="-proto_dist inet6_tcp"
export ECTO_IPV6="true"
export DNS_CLUSTER_QUERY="${FLY_APP_NAME}.internal"
export RELEASE_DISTRIBUTION="name"
export RELEASE_NODE="${FLY_APP_NAME}-${FLY_IMAGE_REF##*-}@${FLY_PRIVATE_IP}"

Then my connection string is configured with a secret in Fly.io:

fly secrets set DATABASE_URL=postgres://...

If I use the default config, then I get the following error connecting with session mode or transaction mode:

17:56:30.334 [error] Postgrex.Protocol (pid<0.167.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (aws-0-us-east-1.pooler.supabase.com:6543): non-existing domain - :nxdomain

Now, if I comment out the IPV6 config line, it works.

#export ECTO_IPV6="true"

I was wondering if any of you got it working under IPV6. It seems today it is supported by both, Fly.io and Supabase but I can’t figure out how to make it work.

How do you set up your database connection from Fly to Supabase?

Most Liked

ntodd

ntodd

Did you ever have a chance to look into this? I’m experiencing the same issues connecting to Supabase on Fly. I’m moving an existing app from another service where it works fine, so this is definitely something Fly or IPv6-specific.

Using :verify_none for demonstration.

Supavisor, IPv4

database_url = "Supavisor DB connection string"

config :foundation, Foundation.Repo,
  ssl: true,
  ssl_opts: [
    verify: :verify_none
  ],
  url: database_url,
  pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10")
  # no ipv6 support enabled
Postgrex.Protocol (#PID<0.2411.0>) timed out because it was handshaking for longer than 15000ms
Postgrex.Protocol (#PID<0.2411.0>) failed to connect: ** (DBConnection.ConnectionError) ssl recv (idle): closed

Supavisor, IPv6

# export ECTO_IPV6="true" in env.sh.eex
database_url = "Supavisor DB connection string"
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []

config :foundation, Foundation.Repo,
  ssl: true,
  ssl_opts: [
    verify: :verify_none
  ],
  url: database_url,
  pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
  socket_options: maybe_ipv6
Postgrex.Protocol (#PID<0.2412.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (aws-0-us-west-1.pooler.supabase.com:5432): non-existing domain - :nxdomain

Direct IPv6 connection URL

# export ECTO_IPV6="true" in env.sh.eex
database_url = "IPv6 direct connection string"
maybe_ipv6 = if System.get_env("ECTO_IPV6") in ~w(true 1), do: [:inet6], else: []

config :foundation, Foundation.Repo,
  ssl: true,
  ssl_opts: [
    verify: :verify_none,
  ],
  url: database_url,
  pool_size: String.to_integer(System.get_env("POOL_SIZE") || "10"),
  socket_options: maybe_ipv6

Works, but runs out of connections after a restart or two:

Postgrex.Protocol (#PID<0.2409.0>) failed to connect: ** (Postgrex.Error) FATAL 53300 (too_many_connections) remaining connection slots are reserved for non-replication superuser connections
dfalling

dfalling

I reached out to Supabase when this was happening for me, and they suggested I up the pool size for my database in database settings. I bumped it from 15 to 25 and it solved it.

Where Next?

Popular in Questions Top

lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
beno
I will often find my self writing things similar to: case some_value do nil -&gt; something() "" -&gt; something() _ -&gt; somethi...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
yawaramin
In the Dialyzer docs ( dialyzer — OTP 29.0.2 (dialyzer 6.0.1) ), there is a way to turn off a specific warning for a function: -dialyzer...
New

Other popular topics Top

chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
Nvim
Anybody knows a comprehensive comparison of Django and Phoenix, thanks for the help. Where are they similar? Where do they differ the m...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement