解决OpenClaw只能本地访问的问题

2026-05-06阅读 0热度 0
OpenClaw 小龙虾

快速部署安装

默认情况下,OpenClaw的控制台只能通过本机访问,也就是只能用“localhost”或“127.0.0.1”来打开。想让局域网内的其他设备也能访问?别急,下面提供了四种解决方案,你可以根据自己当前的环境和偏好来选。

方式一:控制台修改

这种方法有个前提:你得先能在浏览器里访问到控制台页面才行。接下来的操作,都基于默认配置展开。

有件事得先说明一下:

我这里默认用“127.0.0.1”访问是正常的,有些人可能用“localhost”才行。这仅仅是配置上的细微差别,完全不影响后续的操作步骤,大家按自己习惯的来就好。

步骤一:访问控制台

在浏览器地址栏输入:http://127.0.0.1:18789/config

步骤二:修改 Setup Wizard 的 Mode

将默认的“local”选项,改为“remote”。

步骤三:修改 Gateway 的 Bind

将默认的“loopback”选项,改为“lan”。

步骤四:重启 OpenClaw 服务

发现问题:

不过,很多人走到这一步可能会遇到一个拦路虎:页面报错了。

disconnected (1008): control ui requires HTTPS or localhost (secure context)

解决办法:

这时,需要手动修改一下配置文件 openclaw.json。在配置文件里新增一段内容。

修改前:

"gateway": {"port": 18789,"mode": "local","bind": "lan","auth": {"mode": "token","token": "6feca87ceb8134d44ea3148b5fb41d1f40fcc9ed0e7920a9"},"tailscale": {"mode": "off","resetOnExit": false}},

修改后:

"gateway": {"port": 18789,"mode": "local","bind": "lan",// 新增配置"controlUi": {"allowInsecureAuth": true},"auth": {"mode": "token","token": "6feca87ceb8134d44ea3148b5fb41d1f40fcc9ed0e7920a9"},"tailscale": {"mode": "off","resetOnExit": false}},

方式二:通过命令行修改

如果你更习惯用命令行,这几条指令能帮你快速搞定:

# 步骤一:
clawdbot config set gateway.bind lan
# 步骤二:
clawdbot config set gateway.controlUi.allowInsecureAuth true
# 步骤三:
clawdbot gateway restart

# 备注命令说明
# 指定端口
openclaw gateway --port 19000
# 绑定模式
openclaw gateway --bind loopback # 仅本机访问(默认,最安全)
openclaw gateway --bind lan # 局域网可访问
openclaw gateway --bind tailnet # Tailscale 网络
# 通过 Tailscale 暴露服务
openclaw gateway --tailscale serve # 内网暴露
openclaw gateway --tailscale funnel # 公网暴露(需要 Tailscale 账户)

方式三:修改配置文件

直接找到并编辑配置文件,这算是最“底层”的操作方式了。文件路径在这里:

  • Windows路径:C:\Users\user\.openclaw
  • Linux路径:~/.openclaw/openclaw.json

怎么找到这个路径呢?可以参考下图:

找到目录后,就能看到配置文件了:

这里提供一份我的配置文件示例,供你对照修改:

{"meta": {"lastTouchedVersion": "2026.2.2","lastTouchedAt": "2026-02-27T09:17:47.844Z"},"wizard": {"lastRunAt": "2026-02-27T08:55:43.077Z","lastRunVersion": "2026.2.2","lastRunCommand": "onboard","lastRunMode": "remote"},"auth": {"profiles": {"deepseek:default": {"provider": "deepseek","mode": "api_key"}}},"models": {"mode": "merge","providers": {"deepseek": {"baseUrl": "https://api.deepseek.com","api": "openai-completions","models": [{"id": "deepseek-chat","name": "DeepSeek Chat","reasoning": false,"input": ["text"],"cost": {"input": 0.14,"output": 0.28,"cacheRead": 0,"cacheWrite": 0},"contextWindow": 64000,"maxTokens": 4096},{"id": "deepseek-coder","name": "DeepSeek Coder","reasoning": false,"input": ["text"],"cost": {"input": 0.14,"output": 0.28,"cacheRead": 0,"cacheWrite": 0},"contextWindow": 64000,"maxTokens": 4096}]}}},"agents": {"defaults": {"model": {"primary": "deepseek/deepseek-chat"},"models": {"deepseek/deepseek-chat": {"alias": "DeepSeek Chat"}},"workspace": "C:\\Users\\user\\.openclaw\\workspace","compaction": {"mode": "safeguard"},"maxConcurrent": 4,"subagents": {"maxConcurrent": 8}}},"messages": {"ackReactionScope": "group-mentions"},"commands": {"native": "auto","nativeSkills": "auto"},"gateway": {"port": 18789,"mode": "local","bind": "lan","controlUi": {"allowInsecureAuth": true},"auth": {"mode": "token","token": "6feca87ceb8134d44ea3148b5fb41d1f40fcc9ed0e7920a9"},"tailscale": {"mode": "off","resetOnExit": false}},"skills": {"install": {"nodeManager": "pnpm"}}}
免责声明

本网站新闻资讯均来自公开渠道,力求准确但不保证绝对无误,内容观点仅代表作者本人,与本站无关。若涉及侵权,请联系我们处理。本站保留对声明的修改权,最终解释权归本站所有。

相关阅读

更多
欢迎回来 登录或注册后,可保存提示词和历史记录
登录后可同步收藏、历史记录和常用模板
注册即表示同意服务条款与隐私政策