Occasionally our Phoenix app fails to boot due to the below error originating in ranch.
** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, MyAppWeb.Endpoint.HTTP}
** (EXIT) an exception was raised:
** (ArgumentError) errors were found at the given arguments:
* 2nd argument: not a key that exists in the table
(stdlib 3.17.2) :ets.lookup_element(:ranch_server, {:addr, MyAppWeb.Endpoint.HTTP}, 2)
(ranch 1.8.0) /tmp/build_5293a25c/deps/ranch/src/ranch_server.erl:113: :ranch_server.get_addr/1
(phoenix 1.6.14) lib/phoenix/endpoint/cowboy2_adapter.ex:119: Phoenix.Endpoint.Cowboy2Adapter.bound_address/2
(phoenix 1.6.14) lib/phoenix/endpoint/cowboy2_adapter.ex:115: Phoenix.Endpoint.Cowboy2Adapter.info/3
(phoenix 1.6.14) lib/phoenix/endpoint/cowboy2_adapter.ex:101: Phoenix.Endpoint.Cowboy2Adapter.start_link/3
(stdlib 3.17.2) supervisor.erl:414: :supervisor.do_start_child_i/3
(stdlib 3.17.2) supervisor.erl:400: :supervisor.do_start_child/2
(stdlib 3.17.2) supervisor.erl:384: anonymous fn/3 in :supervisor.start_children/2
It appears a specific key is expected to have been set in ets, but for whatever reason, that hasn’t been created yet.
As this doesn’t occur on every bootup, I’m having a hard time debugging and reproducing this issue.
If anyone has any thoughts or suggestions on this, it would be much appreciated.