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
53107

Sign up for updates

Get my latest posts and other insights from work and the web via my Roundup newsletter.

By subscribing, you agree with Revue's Terms of Service and Privacy Policy.