[error] GenServer #PID<0.3686.0> terminating ** (UndefinedFunctionError) function :crypto.hmac/3 is undefined or private

Hi team,
I am pretty much new to phoenix and elixir. I was tring to run a new app from phoenix framework. The steps i followed were:-

  • Installed Erlang otp24.0

  • Installed elixir and then phoenix trough terminal command

I was able to generate a new project using the mix phx.new chat command but when i try to execute

  • mix ecto.create
    I am facing below error

10:52:26.100 [error] GenServer #PID<0.3686.0> terminating
** (UndefinedFunctionError) function :crypto.hmac/3 is undefined or private
(crypto 5.0) :crypto.hmac(:sha256, “Qpppwd1234”, <<81, 176, 19, 229, 33, 227, 55, 191, 246, 209, 54, 238, 100, 18, 169, 248, 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.15) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
Last message: nil
State: Postgrex.Protocol
** (Mix) The database for Discuss.Repo couldn’t be created: killed

Processing: image.png…

Am i missing anything as i have followed the official documention as mentioned on their respective websites.

Postgres is up. confirmed through the pgadmin as well as shell.
Password is also changed in config file as per my postgres setup.


:crypto.hmac was removed in otp 24. You’ll need to make sure all your dependencies are updated and compatible with otp 24.


Hi! The issue here is that postgrex (the library that implements a PostgreSQL database driver) used to use functions that have been deprecated and recently removed in the newest Erlang 24 release. But currently released postgrex and Phoenix versions are already compatible.

How did you install Phoenix? I just installed it anew with mix archive.install hex phx_new 1.5.12 and mix phx.new discuss, and then mix ecto.create succeeded on Erlang 24 without additional steps. Typing mix phx should show installed phoenix version near the top.


Thanks for the reply

  • I first installed erlang otp24 X64 binary from official site.
  • Then installed Elixir through windows web installer ( official site ) and it takes path to above erlang folder.
  • opened cmd and installed phoenix framework through following command:-
    mix archieve.install hex phx_new 1.5.12
  • created a new project :- mix phx.new discuss
  • Ran command :- mix ecto.create
    And got the error.

Just for your info I installed postgres through official installer.

Do we require to make an empty db prior to starting this command?
Or it will be automatically created.
As being from hibernate background we need to manually create an empty db with same name as we want to use.


Thanks fir the reply

Can you pls help me creating one with required dependencies.


Do we require to make an empty db prior to starting this command?
Or it will be automatically created.

The mix ecto.create command is creating a database for you, using credentials from appropriate environment file in config/. But in your case it probably didn’t go that far and errors earlier.

I may find some time to try on Windows some time later this week, but I’m not sure why the behavior would be different… What you did sounds exactly like what should work. For completeness and to be sure, can you paste Phoenix version being printed by mix phx command and the output from elixir --version ?

Just for your information when i tried to change the database and switched from postgres to mssql server, i got a success on windows. ( mix phx.new — Phoenix v1.5.12 )

phx version :- Phoenix v1.5.12
elixir version :-
Erlang/OTP 24 [erts-12.0] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit]

Elixir 1.12.3 (compiled with Erlang/OTP 22)

1 Like

Hi, on windows you have precompiled Elixir with otp 22.