localhost-run
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineselocalhost.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 dev server
localhost - 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)
- 在 开发服务器上接收 webhook(Stripe、GitHub、Twilio 等)
localhost - 从手机或其他网络中的设备测试应用
- 通过 Custom Domain 隧道传输数据库或其他非 HTTP 协议
- 在 localhost.run 上设置 Custom Domain
- 诊断现有 localhost.run 隧道中断、速度缓慢或不稳定的问题
- 替代 ngrok、Cloudflare Tunnel 或 localtunnel 等工具
Quick start
快速开始
Expose a local app on port :
8080bash
ssh -R 80:localhost:8080 localhost.runThe command prints a public URL (something like
) that forwards HTTP and HTTPS traffic to
. Keep the SSH session open; the tunnel dies when it closes.
https://<random>.lhr.lifelocalhost:8080Other 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将本地 端口上的应用暴露到公网:
8080bash
ssh -R 80:localhost:8080 localhost.run该命令会打印一个公共 URL(例如 ),将 HTTP 和 HTTPS 流量转发到 。请保持 SSH 会话开启;会话关闭后,隧道就会中断。
https://<random>.lhr.lifelocalhost:8080其他常用端口:
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 / generalCommand structure
命令结构
ssh -R [customdomain:]bindport:host:hostport localhost.run| Field | Meaning |
|---|---|
| Optional. Reserved for Custom Domain users; pass the full domain here. |
| |
| Local hostname. Usually |
| Local port your app listens on. |
If does not connect, try — some OSes
default to IPv6 while frameworks bind to IPv4 only.
localhost:8080127.0.0.1:8080localhost[::1]ssh -R [customdomain:]bindport:host:hostport localhost.run| 字段 | 含义 |
|---|---|
| 可选。供 Custom Domain 用户使用;在此处传入完整域名。 |
| |
| 本地主机名。通常为 |
| 本地应用监听的端口。 |
如果 无法连接,请尝试 ——某些操作系统默认将 解析为 IPv6 ,而框架仅绑定 IPv4。
localhost:8080127.0.0.1:8080localhost[::1]SSH options
SSH 选项
Forwarded flags work normally. Useful ones:
ssh -obash
undefined转发的 标志可以正常使用。常用选项如下:
ssh -obash
undefinedKeep 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
undefinedautossh -M 0 -R 80:localhost:8080 localhost.run
undefinedOutput formats
输出格式
The server prints one or more URLs. Pick a machine-readable form when
parsing:
bash
undefined服务器会打印一个或多个 URL。进行解析时,请选择便于机器读取的形式:
bash
undefinedHuman-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- Forwards HTTP traffic to your app
- Automatically generates an endpoint with a managed certificate
https:// - Injects proxy headers so frameworks detect the original scheme/host/IP:
X-Forwarded-ForX-Forwarded-HostX-Forwarded-Proto- (RFC 7239)
Forwarded
Disable header injection if a downstream proxy already sets them:
bash
ssh -R 80:localhost:8080 localhost.run -- --no-inject-http-proxy-headersBest 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- 将 HTTP 流量转发到你的应用
- 自动生成 端点,并配发托管证书
https:// - 注入代理标头,使框架能够检测原始 scheme/host/IP:
X-Forwarded-ForX-Forwarded-HostX-Forwarded-Proto- (RFC 7239)
Forwarded
如果下游代理已经设置这些标头,可以禁用标头注入:
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 ,
choose the wire version:
X-Forwarded-*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 v2v1 is the default; v2 is binary and slightly faster
v1 is the default; v2 is binary and slightly faster
undefinedundefinedTLS 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 domains do not expose passthrough endpoints)
lhr.life
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(免费的 域名不提供 passthrough 端点)
lhr.life
如果不想管理证书,请改用 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:
- Use your own domain — bring DNS, get a stable URL
- Use an subdomain — no DNS to configure, first come first served
lhr.rocks
免费套餐会定期轮换域名。若需稳定 URL,请通过 https://admin.localhost.run 注册 Custom Domain 套餐,价格为 $9/月,按年计费。可选择:
- 使用自己的域名——配置 DNS,获得稳定 URL
- 使用 子域名——无需配置 DNS,先到先得
lhr.rocks
Connect with a custom domain
使用自定义域名连接
bash
ssh -R yourdomain.com:80:localhost:8080 plan@localhost.runNote the SSH user. The connection is refused on the default user.
plan@bash
ssh -R yourdomain.com:80:localhost:8080 plan@localhost.run请注意 SSH 用户。使用默认用户时,连接会被拒绝。
plan@DNS setup
DNS 设置
- Add a TXT record at proving ownership
_lhr.yourdomain.com - Either:
- Apex domain (): three A records
example.com54.161.197.24754.82.85.24935.171.254.69
- Subdomain (): one CNAME to
app.example.comcd.localhost.run
- Apex domain (
- Add a wildcard CNAME to unlock unlimited subdomains (
*.yourdomain.com → cd.localhost.run,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.
- 在 处添加一条用于证明所有权的 TXT 记录
_lhr.yourdomain.com - 任选一种:
- 顶级域名():添加三条 A 记录
example.com54.161.197.24754.82.85.24935.171.254.69
- 子域名():添加一条指向
app.example.com的 CNAMEcd.localhost.run
- 顶级域名(
- 添加通配符 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:
- Domain names change regularly (the URL printed on connect is not stable)
- 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短期隧道无需客户端,也无需注册。系统有意设置了两项限制来阻止钓鱼活动:
- 域名会定期变化(连接时打印的 URL 并不稳定)
- 存在速度限制
若想获得有效期更长的免费域名,请在 admin.localhost.run 注册并上传 SSH 公钥。该密钥会将一个稳定的子域名绑定到你的机器。
如果还没有密钥,可以生成一个:
bash
ssh-keygen -t ed25519Upload ~/.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 and set both
relative-urlandWP_HOMEtoWP_SITEURL'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 , the
framework is generating absolute URLs from the request and ignoring proxy
headers. Configure the framework's "trusted proxy" / "reverse proxy" mode
to honor and . Most frameworks
(Fastify, Express, Next.js, Rails, Django, Flask) have this as a setting
or middleware.
localhost:PORTX-Forwarded-ProtoX-Forwarded-Host如果浏览器开发者工具显示请求仍在访问 ,说明框架正在根据请求生成绝对 URL,而忽略了代理标头。请配置框架的“trusted proxy”/“reverse proxy”模式,使其采用 和 。大多数框架(Fastify、Express、Next.js、Rails、Django、Flask)都通过设置项或 middleware 提供此功能。
localhost:PORTX-Forwarded-ProtoX-Forwarded-HostSSH servers (Custom Domain only)
SSH 服务器(仅限 Custom Domain)
Tunneling SSH requires a Custom Domain plus stunnel
on the client to wrap TCP in TLS:
- Open a localhost.run tunnel from the SSH server
- Install stunnel on the client machine
- Configure stunnel to accept local connections and forward them over TLS to the custom domain
- Run the SSH client against the local stunnel endpoint
隧道传输 SSH 需要 Custom Domain,并在客户端安装 stunnel 以将 TCP 封装在 TLS 中:
- 从 SSH 服务器建立 localhost.run 隧道
- 在客户端机器上安装 stunnel
- 配置 stunnel 接受本地连接,并通过 TLS 将其转发到自定义域名
- 通过本地 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 header
X-Forwarded-Proto - TLS passthrough: localhost.run does not decrypt the traffic; your app validates certificates directly
- SSH 传输:无论 HTTP/TLS 设置如何,localhost.run 与本地应用之间均采用端到端加密
- HTTP 隧道:自动签发 HTTPS 端点;由 localhost.run 管理证书。通过注入的 标头配置本地应用强制使用 HTTPS
X-Forwarded-Proto - TLS passthrough:localhost.run 不解密流量;由应用直接验证证书
Troubleshooting
故障排查
| Symptom | Fix |
|---|---|
| Use the |
| Custom domain connection refused | Use the |
| Free tunnel URL keeps changing | Add an SSH key at admin.localhost.run and avoid the |
| Local app is not reachable on that port — verify with |
| Tunnel drops after a few minutes | Add |
| IPv4 / IPv6 mismatch | Try |
App sees | Proxy headers disabled — re-enable injection, or set |
Browser still hits | Framework is generating absolute URLs — configure its reverse-proxy / trusted-proxy setting so it trusts |
| Want to migrate domain to a new account | Cancel the old subscription, set up the domain in the new account, verify with TXT record, pay, then email |
| 症状 | 修复方法 |
|---|---|
免费套餐出现 | 使用 |
| 自定义域名连接被拒绝 | 使用 |
| 免费隧道 URL 不断变化 | 在 admin.localhost.run 添加 SSH 密钥,并避免使用 |
| 本地应用无法通过该端口访问——请在同一台机器上使用 |
| 隧道在几分钟后断开 | 添加 |
| IPv4 / IPv6 不匹配 | 尝试使用 |
应用看到的是 | 代理标头已被禁用——重新启用注入,或在上游代理中设置 |
浏览器仍在访问 | 框架正在生成绝对 URL——配置其 reverse-proxy / trusted-proxy 设置,使其信任 |
| 希望将域名迁移到新账户 | 取消旧订阅,在新账户中设置域名,验证 TXT 记录,付款,然后发送邮件至 |
Reference
参考
- Main docs: https://localhost.run/docs/
- CLI: https://localhost.run/docs/cli/
- HTTP tunnels: https://localhost.run/docs/http-tunnels/
- TLS passthrough: https://localhost.run/docs/tls-passthru-tunnels/
- Custom domains: https://localhost.run/docs/custom-domains/
- Forever free tier: https://localhost.run/docs/forever-free/
- Security: https://localhost.run/docs/security/
- FAQ: https://localhost.run/docs/faq/
- Admin / signup: https://admin.localhost.run
- Source: github.com/localhost-run/site
- 主要文档:https://localhost.run/docs/
- CLI:https://localhost.run/docs/cli/
- HTTP 隧道:https://localhost.run/docs/http-tunnels/
- TLS passthrough 隧道:https://localhost.run/docs/tls-passthru-tunnels/
- 自定义域名:https://localhost.run/docs/custom-domains/
- 永久免费套餐:https://localhost.run/docs/forever-free/
- 安全:https://localhost.run/docs/security/
- FAQ:https://localhost.run/docs/faq/
- 管理后台 / 注册:https://admin.localhost.run
- 源代码:github.com/localhost-run/site