I was working on something completely unrelated — setting up automated OpenID Connect conformance tests — and needed a way to expose a local server over HTTPS without spending money.
After some searching, I found localhost.run, which offers simple SSH-based tunneling. Since I needed tighter integration, I built a small Elixir wrapper around it. What started as a module in my test suite turned into a standalone library: localhost_run.
What’s nice is that it has zero external dependencies — it uses Erlang’s built-in :ssh
module to establish the tunnel and forward ports.
If you ever need to expose a local Elixir app (or anything else running locally) to the internet, this might help.
Available on Hex: https://hex.pm/packages/localhost_run
Example usage
Start a tunnel as a GenServer
:
{:ok, pid} = LocalhostRun.start_link(internal_port: 4000)
Or as a supervised process:
Supervisor.start_link([
{LocalhostRun, internal_port: 4000}
], strategy: :one_for_one)
Get exposed host:
LocalhostRun.get_exposed_host()
The full source is here: https://github.com/erlef/localhost-run — feedback and PRs are welcome!