Could not start application calorie: Calorie.Application.start(:normal, []) returned an error: shutdown: failed to start child: CalorieWeb.Endpoint

Hi,

Everything was fine yesterday. I tried to turn my program today and I am getting this error when I am trying to run mix phx.server. I am not sure what’s happening. I will be greatfull for help.

** (Mix) Could not start application calorie: Calorie.Application.start(:normal, []) returned an error: shutdown: failed to start child: CalorieWeb.Endpoint
    ** (EXIT) shutdown: failed to start child: Phoenix.PubSub.PG2
        ** (EXIT) shutdown: failed to start child: Phoenix.PubSub.PG2Server
            ** (EXIT) an exception was raised:
                ** (UndefinedFunctionError) function :pg2.create/1 is undefined or private
                    (kernel 8.0.1) :pg2.create({:phx, Calorie.PubSub})
                    (phoenix_pubsub 1.1.2) lib/phoenix/pubsub/pg2_server.ex:43: Phoenix.PubSub.PG2Server.init/1
                    (stdlib 3.15.1) gen_server.erl:423: :gen_server.init_it/2
                    (stdlib 3.15.1) gen_server.erl:390: :gen_server.init_it/6
                    (stdlib 3.15.1) proc_lib.erl:226: :proc_lib.init_p_do_apply/3

I feel like I have been summoned with the word “calorie” ;).

but answering your question, you need to either downgrade to OTP < 24, or update Phoenix PubSub to not depend on pg2 as it was removed from Erlang. Check out this thread:

3 Likes

Thanks for reply!

I did update my Phoenix PubSub to “2.0.0” version however it is still receiving same error. I did change my mix.exs, run mix deps.update -- all and mix deps. Am I missing something?

P.S: I am wondering why do you feel like you were summoned my the word “calorie”? :slight_smile:

1 Like

I managed to resolve this issue. I also had to update my phoenix. Thanks for help!

2 Likes

I am obsessed with nutrition :wink:

1 Like

Now I gotta ask do you give consultations :smiley:

2 Likes