问题现象
用户在 Windows 11 上全新安装 OpenClaw 后,完成 onboarding 流程,但在启动 Gateway 时遇到 连接被拒绝 错误:
ERR_CONNECTION_REFUSED
http://127.0.0.1:18789/__openclaw__/canvas/
环境信息:
- OS: Windows 11
- OpenClaw: latest
- Node.js: latest
- 特殊情况:之前安装过 Cladbot
诊断过程
1. 确认 Gateway 状态
# 检查 Gateway 状态
openclaw gateway status
# 可能的输出:
# ❌ Gateway 未运行
# 或
# ⚠️ Gateway 运行中但端口未监听
2. 检查端口占用
# PowerShell - 查看端口 18789 占用情况
netstat -ano | findstr :18789
# 或 PowerShell 5.0+ 方式
Get-NetTCPConnection -LocalPort 18789
# 查看占用进程
Get-Process -Id (Get-NetTCPConnection -LocalPort 18789).OwningProcess
3. 检查残留进程
由于用户之前安装过 Cladbot,可能存在冲突:
# 查找 OpenClaw/Cladbot 相关进程
Get-Process | Where-Object {$_.ProcessName -match "openclaw|cladbot|node"}
# 查找端口监听
netstat -ano | findstr LISTENING | findstr 18789
常见原因
原因 1:端口被占用
症状:Gateway 启动后立即退出 日志:Error: listen EADDRINUSE: address already in use :::18789
解决方案:
# 1. 查找占用进程
netstat -ano | findstr :18789
# 输出:TCP 127.0.0.1:18789 0.0.0.0:0 LISTENING 12345
# ↑ PID
# 2. 结束进程
taskkill /PID 12345 /F
# 或 PowerShell 方式
Stop-Process -Id 12345 -Force
原因 2:残留配置冲突
Cladbot 和 OpenClaw 可能使用相同的配置目录或环境变量。
解决方案:
# 1. 清理环境变量
[Environment]::SetEnvironmentVariable("CLADBOT_HOME", $null, "User")
[Environment]::SetEnvironmentVariable("OPENCLAW_HOME", $null, "User")
# 2. 清理旧配置(谨慎操作!)
# 备份后删除 Cladbot 配置
Rename-Item -Path "$env:USERPROFILE\.cladbot" -NewName "$env:USERPROFILE\.cladbot.backup"
# 3. 重新初始化 OpenClaw
openclaw onboard
原因 3:权限问题
Windows 可能需要管理员权限绑定端口。
解决方案:
# 以管理员身份运行 PowerShell,然后
openclaw gateway restart
# 或修改端口为高位端口(不需要管理员权限)
# 在 openclaw.json 中:
{
"gateway": {
"port": 58789 # ← 改为高位端口
}
}

