Reputation: 53
I'm getting the following error when starting my app in production mode. All works fine on dev side, can migrate, compile and release without issue on the production app but when running it, it crashes on start. I'm sure it is something very obvious I am missing. I am running Erlang 19 and Elixir 1.3.2.
17:42:52.768 [info] Application curriculum exited: Curriculum.start(:normal, []) returned an error: shutdown: failed to start child: Curriculum.Endpoint ** (EXIT) shutdown: failed to start child: Phoenix.Endpoint.Server ** (EXIT) an exception was raised: ** (FunctionClauseError) no function clause matching in System.get_env/1 (elixir) lib/system.ex:358: System.get_env(4000) (phoenix) lib/phoenix/endpoint/server.ex:34: Phoenix.Endpoint.Server.to_port/1 (phoenix) lib/phoenix/endpoint/server.ex:28: Phoenix.Endpoint.Server.default/3 (phoenix) lib/phoenix/endpoint/server.ex:17: anonymous fn/5 in Phoenix.Endpoint.Server.init/1 (elixir) lib/enum.ex:1623: Enum."-reduce/3-lists^foldl/2-0-"/3 (phoenix) lib/phoenix/endpoint/server.ex:15: Phoenix.Endpoint.Server.init/1 (stdlib) supervisor.erl:294: :supervisor.init/1 (stdlib) gen_server.erl:328: :gen_server.init_it/6 {"Kernel pid terminated",application_controller,"{application_start_failure,curriculum,{{shutdown,{failed_to_start_child,'Elixir.Curriculum.Endpoint',{shutdown,{failed_to_start_child,'Elixir.Phoenix.Endpoint.Server',{function_clause,[{'Elixir.System',get_env,[4000],[{file,\"lib/system.ex\"},{line,358}]},{'Elixir.Phoenix.Endpoint.Server',to_port,1,[{file,\"lib/phoenix/endpoint/server.ex\"},{line,34}]},{'Elixir.Phoenix.Endpoint.Server',default,3,[{file,\"lib/phoenix/endpoint/server.ex\"},{line,28}]},{'Elixir.Phoenix.Endpoint.Server','-init/1-fun-0-',5,[{file,\"lib/phoenix/endpoint/server.ex\"},{line,17}]},{'Elixir.Enum','-reduce/3-lists^foldl/2-0-',3,[{file,\"lib/enum.ex\"},{line,1623}]},{'Elixir.Phoenix.Endpoint.Server',init,1,[{file,\"lib/phoenix/endpoint/server.ex\"},{line,15}]},{supervisor,init,1,[{file,\"supervisor.erl\"},{line,294}]},{gen_server,init_it,6,[{file,\"gen_server.erl\"},{line,328}]}]}}}}},{'Elixir.Curriculum',start,[normal,[]]}}}"}
Prod.exs file contents
http: [port: {:system, 4000}],url: [host: "example.com"],cache_static_manifest: "priv/static/manifest.json",server: true
config :phoenix, :serve_endpoints, true
import_config "prod.secret.exs"
Upvotes: 4
Views: 4068
Reputation: 222040
Your value for port
in config/prod.exs
is wrong. It should either be:
port: 4000
to always run on port 4000, or:
port: {:system, "PORT"}
to read the port from the environment variable PORT
(you can change the name to any other string).
Upvotes: 3