LocalhostRun - A small Elixir client for localhost.run, which lets you expose local ports to the internet via SSH tunnels.

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.

:package: 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!

11 Likes

I think it would be worth putting a fat warning in README to use patched versions of OTP (following the recent vulnerability)? Or maybe even go a step further and warn in console if you are using a non-patched version?

As far as I understand :ssh is only affected when run as a server and not as a client. For this library, localhost.run runs an SSH server and this library connect as a client.

(ssh CVE fix: ssh: early RCE fix · erlang/otp@6eef041 · GitHub)

3 Likes

Thankyou Sir,

This is would help me to develop locally and and showing my project to my client. Bookmarked!

1 Like