更新时间:2026-03-11
背景说明
OpenClaw 默认监听 127.0.0.1:18789,仅本机可访问。若要在局域网内其他设备(如手机、平板、其他电脑)访问 OpenClaw,需要修改配置使其绑定到局域网可访问的地址。
通常报错为:origin not allowed (open the Control UI from the gateway host or allow it in gateway.controlUi.allowedOrigins)
操作步骤
第一步:允许局域网访问
openclaw config set gateway.bind lan作用:将网关从
loopback(仅本地)模式切换为lan(局域网/公网可访问)模式
第二步:允许非安全认证(解决 origin 限制的关键)
openclaw config set gateway.controlUi.allowInsecureAuth true第三步:(可选)禁用设备认证
openclaw config set gateway.controlUi.dangerouslyDisableDeviceAuth true⚠️ 注意:此步骤会降低安全性,仅在可信局域网内使用
第四步:获取本机局域网 IP
根据操作系统执行对应命令:
ipconfig | |
hostname -I | |
ifconfig |
第五步:配置允许的来源 Origins(解决跨域访问)
openclaw config set 'gateway.controlUi.allowedOrigins' '["http://192.168.1.136:18789"]'将
192.168.1.136替换为你实际的局域网 IP 地址
第六步:重启网关使配置生效
openclaw gateway restart第七步:验证服务监听状态
openclaw gateway status预期输出:0.0.0.0:18789 或 192.168.x.x:18789(而非 127.0.0.1:18789)
第八步:从局域网其他设备访问
http://<openclaw所在机器的局域网ip>:18789</openclaw所在机器的局域网ip>示例:http://192.168.1.100:18789
第九步:配置令牌(如需)
首次访问可能需要输入Gateway Token。
获取 Token:
cat ~/.openclaw/openclaw.json | grep -o '"token":"[^"]*"' | cut -d'"' -f4将获取的 Token 输入浏览器页面中的「网关令牌」字段即可。
故障排查
gateway.bind 为 lan | |
openclaw gateway restart |
夜雨聆风