SSL connections for Postgrex in Livebook

I am trying to query a Postgres database that requires SSL connections from a Livebook session.

opts = [
  hostname: "database.url.com",
  port: 5432,
  username: "username",
  password: "password",
  database: "my_db",
  ssl: true
]

{:ok, conn} = Postgrex.start_link(opts)

The result of evaluating this cell is:

** (RuntimeError) SSL connection can not be established because `:ssl` application is not started,
you can add it to `extra_applications` in your `mix.exs`:

  def application do
    [extra_applications: [:ssl]]
  end

    (postgrex 0.16.3) lib/postgrex.ex:652: Postgrex.ensure_deps_started!/1
    (postgrex 0.16.3) lib/postgrex.ex:267: Postgrex.start_link/1

The livebook is running inside the livebook/livebook Docker container per the instructions on the readme.

How can I start the SSL application for my Livebook session?

Hey @msharp welcome! You can simply do :ssl.start()

2 Likes

Thankyou @benwilson512