localhost-run

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

localhost.run

localhost.run

localhost.run is a client-less tunneling service that makes locally running HTTP, HTTPS, or TLS applications reachable from the public internet. There is no client to install and no account needed for the free tier — it works over plain SSH, which is already available on most operating systems.
localhost.run 是一种无需客户端的隧道服务,可让本地运行的 HTTP、HTTPS 或 TLS 应用从公共互联网访问。免费套餐无需安装客户端,也无需注册账户——它通过普通 SSH 工作,而大多数操作系统都已提供 SSH。

When to use this skill

何时使用此 skill

Use this skill when the user wants to:
  • Share a locally running app with someone (preview link, demo, QA)
  • Receive webhooks (Stripe, GitHub, Twilio, etc.) on a
    localhost
    dev server
  • Test an app from a phone or another device on a different network
  • Tunnel a database or other non-HTTP protocol through a Custom Domain
  • Set up a Custom Domain on localhost.run
  • Diagnose an existing localhost.run tunnel that is broken, slow, or unstable
  • Replace tools like ngrok, Cloudflare Tunnel, or localtunnel
当用户希望执行以下操作时,使用此 skill:
  • 与其他人共享本地运行的应用(预览链接、演示、QA)
  • 在
    localhost
    开发服务器上接收 webhook(Stripe、GitHub、Twilio 等)
  • 从手机或其他网络中的设备测试应用
  • 通过 Custom Domain 隧道传输数据库或其他非 HTTP 协议
  • 在 localhost.run 上设置 Custom Domain
  • 诊断现有 localhost.run 隧道中断、速度缓慢或不稳定的问题
  • 替代 ngrok、Cloudflare Tunnel 或 localtunnel 等工具

Quick start

快速开始

Expose a local app on port
8080
:
bash
ssh -R 80:localhost:8080 localhost.run
The command prints a public URL (something like
https://<random>.lhr.life
) that forwards HTTP and HTTPS traffic to
localhost:8080
. Keep the SSH session open; the tunnel dies when it closes.
Other common ports:
bash
ssh -R 80:localhost:3000 localhost.run   # Node / React dev server
ssh -R 80:localhost:5000 localhost.run   # Flask / general
ssh -R 80:localhost:8000 localhost.run   # Django / general
将本地
8080
端口上的应用暴露到公网:
bash
ssh -R 80:localhost:8080 localhost.run
该命令会打印一个公共 URL(例如
https://<random>.lhr.life
),将 HTTP 和 HTTPS 流量转发到
localhost:8080
。请保持 SSH 会话开启;会话关闭后,隧道就会中断。
其他常用端口:
bash
ssh -R 80:localhost:3000 localhost.run   # Node / React dev server
ssh -R 80:localhost:5000 localhost.run   # Flask / general
ssh -R 80:localhost:8000 localhost.run   # Django / general

Command structure

命令结构

ssh -R [customdomain:]bindport:host:hostport localhost.run
FieldMeaning
customdomain
Optional. Reserved for Custom Domain users; pass the full domain here.
bindport
80
for HTTP (HTTPS auto-provided),
443
for TLS passthrough.
host
Local hostname. Usually
localhost
. Use
127.0.0.1
if IPv6 misbehaves.
hostport
Local port your app listens on.
If
localhost:8080
does not connect, try
127.0.0.1:8080
— some OSes default
localhost
to IPv6
[::1]
while frameworks bind to IPv4 only.
ssh -R [customdomain:]bindport:host:hostport localhost.run
字段含义
customdomain
可选。供 Custom Domain 用户使用;在此处传入完整域名。
bindport
80
用于 HTTP(自动提供 HTTPS),
443
用于 TLS passthrough。
host
本地主机名。通常为
localhost
。如果 IPv6 出现问题,请使用
127.0.0.1
。
hostport
本地应用监听的端口。
如果
localhost:8080
无法连接,请尝试
127.0.0.1:8080
——某些操作系统默认将
localhost
解析为 IPv6
[::1]
,而框架仅绑定 IPv4。

SSH options

SSH 选项

Forwarded
ssh -o
flags work normally. Useful ones:
bash
undefined
转发的
ssh -o
标志可以正常使用。常用选项如下:
bash
undefined

Keep the tunnel alive across NAT/router timeouts

Keep the tunnel alive across NAT/router timeouts

ssh -o ServerAliveInterval=60 -R 80:localhost:8080 localhost.run
ssh -o ServerAliveInterval=60 -R 80:localhost:8080 localhost.run

Background it with autossh for auto-reconnect

Background it with autossh for auto-reconnect

autossh -M 0 -R 80:localhost:8080 localhost.run
undefined
autossh -M 0 -R 80:localhost:8080 localhost.run
undefined

Output formats

输出格式

The server prints one or more URLs. Pick a machine-readable form when parsing:
bash
undefined
服务器会打印一个或多个 URL。进行解析时,请选择便于机器读取的形式:
bash
undefined

Human-readable (default)

Human-readable (default)

ssh -R 80:localhost:8080 localhost.run -- --output text
ssh -R 80:localhost:8080 localhost.run -- --output text

JSON

JSON

ssh -R 80:localhost:8080 localhost.run -- --output json

Pass anything after `--` to forward flags to localhost.run rather than ssh.
ssh -R 80:localhost:8080 localhost.run -- --output json

`--` 之后的任何内容都会转发给 localhost.run,而不是 ssh。

HTTP tunnels

HTTP 隧道

bindport 80
is the default mode. localhost.run:
  • Forwards HTTP traffic to your app
  • Automatically generates an
    https://
    endpoint with a managed certificate
  • Injects proxy headers so frameworks detect the original scheme/host/IP:
    • X-Forwarded-For
    • X-Forwarded-Host
    • X-Forwarded-Proto
    • Forwarded
      (RFC 7239)
Disable header injection if a downstream proxy already sets them:
bash
ssh -R 80:localhost:8080 localhost.run -- --no-inject-http-proxy-headers
Best practice: configure the local app to require HTTPS — it is given the correct scheme through the injected headers, so trusted clients see the right URLs and assets.
bindport 80
是默认模式。localhost.run:
  • 将 HTTP 流量转发到你的应用
  • 自动生成
    https://
    端点,并配发托管证书
  • 注入代理标头,使框架能够检测原始 scheme/host/IP:
    • X-Forwarded-For
    • X-Forwarded-Host
    • X-Forwarded-Proto
    • Forwarded
      (RFC 7239)
如果下游代理已经设置这些标头,可以禁用标头注入:
bash
ssh -R 80:localhost:8080 localhost.run -- --no-inject-http-proxy-headers
最佳实践:配置本地应用强制使用 HTTPS——应用会通过注入的标头获知正确的 scheme,从而让受信任的客户端看到正确的 URL 和资源。

Proxy protocol

代理协议

For apps that consume the HAProxy proxy protocol instead of
X-Forwarded-*
, choose the wire version:
bash
ssh -R 80:localhost:8080 localhost.run -- --proxy-protocol-header-version v2
对于使用 HAProxy proxy protocol 而不是
X-Forwarded-*
的应用,请选择协议版本:
bash
ssh -R 80:localhost:8080 localhost.run -- --proxy-protocol-header-version v2

v1 is the default; v2 is binary and slightly faster

v1 is the default; v2 is binary and slightly faster

undefined
undefined

TLS passthrough

TLS passthrough

For non-HTTP protocols (PostgreSQL, SSH-over-TLS, custom TCP) where the application must see raw TLS bytes and validate the certificate itself:
bash
ssh -R 443:localhost:8443 localhost.run
  • Your app is responsible for providing and validating its own TLS cert
  • Currently requires a Custom Domain (free
    lhr.life
    domains do not expose passthrough endpoints)
If you do not want to manage certificates, use an HTTP tunnel instead — localhost.run handles TLS termination.
对于应用必须接收原始 TLS 字节并自行验证证书的非 HTTP 协议(PostgreSQL、SSH-over-TLS、自定义 TCP):
bash
ssh -R 443:localhost:8443 localhost.run
  • 你的应用负责提供并验证自己的 TLS 证书
  • 目前需要 Custom Domain(免费的
    lhr.life
    域名不提供 passthrough 端点)
如果不想管理证书,请改用 HTTP 隧道——localhost.run 会处理 TLS termination。

Custom domains

自定义域名

The free tier rotates domain names regularly. For a stable URL, sign up for the Custom Domain plan at $9/month billed annually via https://admin.localhost.run. Two options:
  1. Use your own domain — bring DNS, get a stable URL
  2. Use an
    lhr.rocks
    subdomain
    — no DNS to configure, first come first served
免费套餐会定期轮换域名。若需稳定 URL,请通过 https://admin.localhost.run 注册 Custom Domain 套餐,价格为 $9/月,按年计费。可选择:
  1. 使用自己的域名——配置 DNS,获得稳定 URL
  2. 使用
    lhr.rocks
    子域名
    ——无需配置 DNS,先到先得

Connect with a custom domain

使用自定义域名连接

bash
ssh -R yourdomain.com:80:localhost:8080 plan@localhost.run
Note the
plan@
SSH user. The connection is refused on the default user.
bash
ssh -R yourdomain.com:80:localhost:8080 plan@localhost.run
请注意
plan@
SSH 用户。使用默认用户时,连接会被拒绝。

DNS setup

DNS 设置

  1. Add a TXT record at
    _lhr.yourdomain.com
    proving ownership
  2. Either:
    • Apex domain (
      example.com
      ): three A records
      • 54.161.197.247
      • 54.82.85.249
      • 35.171.254.69
    • Subdomain (
      app.example.com
      ): one CNAME to
      cd.localhost.run
  3. Add a wildcard CNAME
    *.yourdomain.com → cd.localhost.run
    to unlock unlimited subdomains (
    api.yourdomain.com
    ,
    web.yourdomain.com
    , …)
Limits: up to 5 simultaneous tunnels per plan; subdomain count is bounded by Let's Encrypt certificate rate limits.
Manage billing, add SSH keys, change or cancel domains at https://admin.localhost.run.
  1. 在
    _lhr.yourdomain.com
    处添加一条用于证明所有权的 TXT 记录
  2. 任选一种:
    • 顶级域名(
      example.com
      ):添加三条 A 记录
      • 54.161.197.247
      • 54.82.85.249
      • 35.171.254.69
    • 子域名(
      app.example.com
      ):添加一条指向
      cd.localhost.run
      的 CNAME
  3. 添加通配符 CNAME
    *.yourdomain.com → cd.localhost.run
    ,以启用无限子域名(
    api.yourdomain.com
    、
    web.yourdomain.com
    等)
限制:每个套餐最多同时建立 5 条隧道;子域名数量受 Let's Encrypt 证书签发速率限制。
可在 https://admin.localhost.run 管理账单、添加 SSH 密钥、更改或取消域名。

Forever free tier

永久免费套餐

No client, no signup required for short-lived tunnels. Two intentional restrictions to deter phishing:
  1. Domain names change regularly (the URL printed on connect is not stable)
  2. There is a speed limit
To get a longer-lasting free domain, sign up at admin.localhost.run and upload an SSH public key. The key binds a stable subdomain to your machine.
Generate a key if you do not have one:
bash
ssh-keygen -t ed25519
短期隧道无需客户端,也无需注册。系统有意设置了两项限制来阻止钓鱼活动:
  1. 域名会定期变化(连接时打印的 URL 并不稳定)
  2. 存在速度限制
若想获得有效期更长的免费域名,请在 admin.localhost.run 注册并上传 SSH 公钥。该密钥会将一个稳定的子域名绑定到你的机器。
如果还没有密钥,可以生成一个:
bash
ssh-keygen -t ed25519

Upload ~/.ssh/id_ed25519.pub to https://admin.localhost.run

Upload ~/.ssh/id_ed25519.pub to https://admin.localhost.run


Custom Domain plans are not subject to either restriction.

Custom Domain 套餐不受上述任一限制。

Tunnel my <thing>

隧道传输我的 <thing>

Common patterns documented on the site:
网站上记录了以下常见模式:

WordPress

WordPress

WordPress stores the site URL in the database, so rotating free domains break it. Either:
  • Use a Custom Domain (recommended for any WordPress site)
  • Or with a free domain, install
    relative-url
    and set both
    WP_HOME
    and
    WP_SITEURL
    to
    'https://' . $_SERVER['HTTP_HOST']
WordPress 会将站点 URL 存储在数据库中,因此轮换的免费域名会导致其失效。可以:
  • 使用 Custom Domain(任何 WordPress 站点都推荐使用此方案)
  • 或者在使用免费域名时安装
    relative-url
    ,并将
    WP_HOME
    和
    WP_SITEURL
    都设置为
    'https://' . $_SERVER['HTTP_HOST']

Web frameworks

Web 框架

If the browser dev tools show requests still going to
localhost:PORT
, the framework is generating absolute URLs from the request and ignoring proxy headers. Configure the framework's "trusted proxy" / "reverse proxy" mode to honor
X-Forwarded-Proto
and
X-Forwarded-Host
. Most frameworks (Fastify, Express, Next.js, Rails, Django, Flask) have this as a setting or middleware.
如果浏览器开发者工具显示请求仍在访问
localhost:PORT
,说明框架正在根据请求生成绝对 URL,而忽略了代理标头。请配置框架的“trusted proxy”/“reverse proxy”模式,使其采用
X-Forwarded-Proto
和
X-Forwarded-Host
。大多数框架(Fastify、Express、Next.js、Rails、Django、Flask)都通过设置项或 middleware 提供此功能。

SSH servers (Custom Domain only)

SSH 服务器(仅限 Custom Domain)

Tunneling SSH requires a Custom Domain plus stunnel on the client to wrap TCP in TLS:
  1. Open a localhost.run tunnel from the SSH server
  2. Install stunnel on the client machine
  3. Configure stunnel to accept local connections and forward them over TLS to the custom domain
  4. Run the SSH client against the local stunnel endpoint
隧道传输 SSH 需要 Custom Domain,并在客户端安装 stunnel 以将 TCP 封装在 TLS 中:
  1. 从 SSH 服务器建立 localhost.run 隧道
  2. 在客户端机器上安装 stunnel
  3. 配置 stunnel 接受本地连接,并通过 TLS 将其转发到自定义域名
  4. 通过本地 stunnel 端点运行 SSH 客户端

Security

安全

  • SSH transport: end-to-end encrypted between localhost.run and your local app regardless of HTTP/TLS settings
  • HTTP tunnels: HTTPS endpoints are auto-issued; localhost.run handles certificate management. Configure the local app to require HTTPS via the injected
    X-Forwarded-Proto
    header
  • TLS passthrough: localhost.run does not decrypt the traffic; your app validates certificates directly
  • SSH 传输:无论 HTTP/TLS 设置如何,localhost.run 与本地应用之间均采用端到端加密
  • HTTP 隧道:自动签发 HTTPS 端点;由 localhost.run 管理证书。通过注入的
    X-Forwarded-Proto
    标头配置本地应用强制使用 HTTPS
  • TLS passthrough:localhost.run 不解密流量;由应用直接验证证书

Troubleshooting

故障排查

SymptomFix
Permission denied (publickey)
on the free tier
Use the
nokey
user:
ssh -R 80:localhost:8080 nokey@localhost.run
Custom domain connection refusedUse the
plan
user:
ssh -R yourdomain.com:80:localhost:8080 plan@localhost.run
Free tunnel URL keeps changingAdd an SSH key at admin.localhost.run and avoid the
nokey
user
connect_to localhost port 8080: failed
Local app is not reachable on that port — verify with
curl http://localhost:8080
from the same machine
Tunnel drops after a few minutesAdd
ssh -o ServerAliveInterval=60
, or wrap in
autossh -M 0 -R 80:localhost:8080 localhost.run
for auto-reconnect
IPv4 / IPv6 mismatchTry
127.0.0.1
instead of
localhost
(or vice versa)
App sees
http://
instead of
https://
Proxy headers disabled — re-enable injection, or set
X-Forwarded-Proto: https
in the upstream proxy. Configure the framework's "trust proxy" mode.
Browser still hits
localhost:PORT
Framework is generating absolute URLs — configure its reverse-proxy / trusted-proxy setting so it trusts
X-Forwarded-Host
Want to migrate domain to a new accountCancel the old subscription, set up the domain in the new account, verify with TXT record, pay, then email
help@localhost.run
to transfer remaining credit
症状修复方法
免费套餐出现
Permission denied (publickey)
使用
nokey
用户:
ssh -R 80:localhost:8080 nokey@localhost.run
自定义域名连接被拒绝使用
plan
用户:
ssh -R yourdomain.com:80:localhost:8080 plan@localhost.run
免费隧道 URL 不断变化在 admin.localhost.run 添加 SSH 密钥,并避免使用
nokey
用户
connect_to localhost port 8080: failed
本地应用无法通过该端口访问——请在同一台机器上使用
curl http://localhost:8080
验证
隧道在几分钟后断开添加
ssh -o ServerAliveInterval=60
,或使用
autossh -M 0 -R 80:localhost:8080 localhost.run
自动重连
IPv4 / IPv6 不匹配尝试使用
127.0.0.1
代替
localhost
,或反之
应用看到的是
http://
而不是
https://
代理标头已被禁用——重新启用注入,或在上游代理中设置
X-Forwarded-Proto: https
。配置框架的“trust proxy”模式。
浏览器仍在访问
localhost:PORT
框架正在生成绝对 URL——配置其 reverse-proxy / trusted-proxy 设置,使其信任
X-Forwarded-Host
希望将域名迁移到新账户取消旧订阅,在新账户中设置域名,验证 TXT 记录,付款,然后发送邮件至
help@localhost.run
以转移剩余额度

Reference

参考