Not able to start the phoenix app

Hi,

I am new elixir world and I am trying to run my first phoenix app. I have ran the mix phx.new command and then installed all the dependences as well. But when I run mix phx.server, I am getting this error.

[error] GenServer #PID<0.4365.0> terminating
** (UndefinedFunctionError) function :crypto.hmac/3 is undefined or private
    (crypto 5.0.3) :crypto.hmac(:sha256, "postgres", <<58, 35, 165, 97, 41, 104, 150, 113, 67, 53, 62, 175, 175, 213, 142, 78, 0, 0, 0, 1>>)
    (postgrex 0.15.0) lib/postgrex/scram.ex:52: Postgrex.SCRAM.hash_password/6
    (postgrex 0.15.0) lib/postgrex/scram.ex:26: Postgrex.SCRAM.verify/2
    (postgrex 0.15.0) lib/postgrex/protocol.ex:734: Postgrex.Protocol.auth_cont/4
    (postgrex 0.15.0) lib/postgrex/protocol.ex:579: Postgrex.Protocol.handshake/2
    (db_connection 2.4.0) lib/db_connection/connection.ex:82: DBConnection.Connection.connect/2
    (connection 1.1.0) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.16) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol

Elixir version:

Erlang/OTP 24 [erts-12.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace]

Elixir 1.12.3 (compiled with Erlang/OTP 24)

OS: Macos Bigsur 11.6

Thanks! :smiley:

:crypto.hmac was removed in OTP 24 after being deprecated before. Make sure you run the latest versions of your dependencies and that those are compatible with OTP 24.

If you’re just starting with elixir. I would just install through asdf. That way you can use multiple versions of elixir and erlang both locally and globally.

Hi Thank you for the reply. I just followed the getting started documentation. Here is my mix.exs dependency list

      {:phoenix, "~> 1.5.8"},
      {:phoenix_ecto, "~> 4.1"},
      {:ecto_sql, "~> 3.4"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_html, "~> 2.11"},
      {:phoenix_live_reload, "~> 1.2", only: :dev},
      {:phoenix_live_dashboard, "~> 0.4"},
      {:telemetry_metrics, "~> 0.4"},
      {:telemetry_poller, "~> 0.4"},
      {:gettext, "~> 0.11"},
      {:jason, "~> 1.0"},
      {:plug_cowboy, "~> 2.0"}

I tried running mix deps.update --all

Still I am getting the same error.

Where should I do the change?

You need at least version 0.15.8 of the postgrex package: postgrex/CHANGELOG.md at master · elixir-ecto/postgrex · GitHub