Debugging Ecto connections to remote Postgres servers in Mix tasks

Hey folks, I’m trying to use Ecto with Neon’s hosted Postgres service. Notably, this necessitates the use of SNI to connect to the right server.

My config.exs looks like this:

import Config

config :friends, Friends.Repo,
  url: "postgres://application:nunyabidn355@ep-still-thunder-16014280.us-west-2.aws.neon.tech/friends?options=project%3Dep-still-thunder-16014280",
  # database: "friends",
  # username: "application",
  # password: "nunyabidn355",
  # hostname: "ep-still-thunder-16014280.us-west-2.aws.neon.tech",
  # port: 5432,
  ssl: true,
  ssl_opts: [
    server_name_indication: 'ep-still-thunder-16014280.us-west-2.aws.neon.tech',
    verify: :verify_none
  ]

config :friends, ecto_repos: [Friends.Repo]

mix ecto.create reports a cryptic ** (Mix) The database for Friends.Repo couldn't be created: killed and mix ecto.migrate simply reports ** (EXIT from #PID<0.99.0>) shutdown.

So, the real question I have is, how do I coerce mix into giving me some debug output so I can see what’s actually going on? In other words, I’m not interested in the answer to what’s happening here; instead I’m interested in how I might arrive at that answer myself.

1 Like

Did you discover a solution to debugging this? I seem to be in the same situation.

Current vibe: xkcd: Wisdom of the Ancients

I ended up using the sample code that connects without verifying the cert. Not great, but for my current use-case, fine. I planned to revisit when/if I ever get to some semblance of production.

Thanks for your reply! Will post if I figure it out. (I really need to figure it out.)