function Ecto.Adapters.Postgres.child_specs/2 is undefined or private

I’m trying to upgrade an old project and after following the upgrade, now when I try to run the app I get the following error.
Could not start application groovejar_app: GroovejarApp.start(:normal, []) returned an error: shutdown: failed to start child: GroovejarApp.Endpoint ** (EXIT) an exception was raised: ** (UndefinedFunctionError) function Ecto.Adapters.Postgres.child_specs/2 is undefined or private

Here’s my mix.esx file. Any idea on what I’m missing would be greatly appreciated.
`def project do
app: :groovejar_app,
version: “0.0.1”,
elixir: “~> 1.13.2”,
elixirc_paths: elixirc_paths(Mix.env),
compilers: [:phoenix, :gettext] ++ Mix.compilers,
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
aliases: aliases(),
deps: deps()
defp deps do

[{:phoenix, "~> 1.5.9"},

 {:phoenix_pubsub, "~> 2.0"},

 {:postgrex, ">= 0.0.0"},

 {:ecto, "~> 3.7.1"},

 {:ecto_sql , "~>3.4"},

 {:phoenix_ecto, "~> 4.0"},

 {:phoenix_html, "~> 2.11"},

 {:phoenix_live_reload, "~> 1.2"},

 {:gettext, "~> 0.9"},

 {:cowboy, "~> 2.7"},

 {:plug_cowboy, "~> 2.1"},

 # {:shopify, "~> 0.1.5", git: ""},

 # {:shopify, "~> 0.1.5", path: "../shopify"},

 {:poison, "~> 3.0", override: true},

 # {:quantum, ">= 2.0.0-beta.1"},

 {:timex, "~> 3.0"},

 {:ex_machina, "~> 0.0", only: :test},

 {:faker, "~> 0.7"},

 {:httpoison, "~> 0.8.3", override: true},

 {:uuid, "~> 1.1" },

 {:exredis, ">= 0.2.4"},

{:telemetry, "~> 0.4"},

{:jason, "~> 1.0"},

#  {:sentry, "~> 6.0"},

 {:hackney, "~> 1.15", override: true}



It should be child_spec (singular) and NOT child_specs (plural). Where do you have child_specs in the code?

I do not have the child_specs mentioned in my code, explicitly. Tried searching through my code as well with no luck. However, the same code has been working fine with the older version of elixir. Not sure if this may have something to do with the ecto & ecto_sql version.

Try also looking in your deps and not only your code?

To not respect .gitignore I would use this command:

rg -uu child_specs

Thanks @dimitarvp this is occurring in the supervisor and cowboy_adapter. See.
154: (user_adapter || autodetected_adapter).child_specs(mod, config)

81: def child_specs(endpoint, config) do

51: def child_specs(endpoint, config) do
67: {refs, child_specs} = Enum.unzip(refs_and_specs)
70: child_specs ++ [{Plug.Cowboy.Drainer, Keyword.put_new(drainer, :refs, refs)}]
72: child_specs`

Ah, I really have no idea why your original problem occurred. Just teaching you how to search for the offenders.

Welcome to the forum :rocket:

The error occurs when trying to start the Endpoint, and it’s complaining about Ecto.Adapters.Postgres.child_specs/2 being undefined.

Line 154 is trying to call the child_specs/2 function defined by the variable user_adapter, which is set by the code from the endpoint configuration in your config.exs.

If you inspect the code in deps\phoenix\lib\phoenix\endpoint\supervisor.ex for this version of Phoenix, which I assume is 1.5.13 because your deps is {:phoenix, "~> 1.5.9"}, you’ll see this:

defp server_children(mod, config, server?) do
  if server? do
    user_adapter = user_adapter(mod, config)
    autodetected_adapter = cowboy_version_adapter()
    warn_on_different_adapter_version(user_adapter, autodetected_adapter, mod)
    (user_adapter || autodetected_adapter).child_specs(mod, config)

defp user_adapter(endpoint, config) do
  case config[:handler] do
    nil ->

    Phoenix.Endpoint.CowboyHandler ->
      Logger.warn "Phoenix.Endpoint.CowboyHandler is deprecated, please use Phoenix.Endpoint.CowboyAdapter instead"

    other ->
      Logger.warn "The :handler option in #{inspect endpoint} is deprecated, please use :adapter instead"

See if your endpoint has incorrectly set adapter: Ecto.Adapters.Postgres.

1 Like