TIL Determine which HTTP port is being used by a Phoenix app

Phoenix port screenshot

Today I learned: How to determine which HTTP port a Phoenix app is using

I was recently starting a Phoenix server with port 0 which tells the OS to find a free local port but wanted to know what port it had chosen.

It turns out you can query the ranch config by the module name of your Phoenix Endpoint to get this information:

iex> :ranch.get_port MyAppWeb.Endpoint.HTTP