在 VPS 上配置 OpenClaw 浏览器功能时,默认配置会报错:Error: Chrome extension relay is running, but no tab is connected。这是因为默认使用 chrome profile(需要浏览器扩展),而 VPS 上无法使用图形界面。本文详细介绍解决方案。
一、安装 Playwright 浏览器
OpenClaw 依赖 Playwright 来驱动浏览器。首先检查是否已安装:
npx playwright --version
如果没有,安装 Chromium:
npx playwright install chromium
安装后会显示浏览器路径,例如:/root/.cache/ms-playwright/chromium-1208/chrome-linux64/chrome
二、修改配置文件
编辑 ~/.openclaw/openclaw.json,在 hooks 和 web 之间添加 browser 配置:
{
"browser": {
"enabled": true,
"defaultProfile": "openclaw",
"headless": true,
"noSandbox": true,
"executablePath": "/root/.cache/ms-playwright/chromium-1208/chrome-linux64/chrome",
"profiles": {
"openclaw": {
"cdpPort": 18792,
"color": "#FF6B00"
}
}
}
}
关键配置说明:
defaultProfile: "openclaw" - 使用管理模式,不需要扩展
headless: true - 无头模式,VPS 必须
noSandbox: true - 某些 Linux 环境需要禁用沙盒
executablePath - 指定 Playwright 安装的浏览器路径
三、启用 browser 工具
在 tools.byProvider 中添加 browser 到白名单:
{
"tools": {
"byProvider": {
"claude-fucheers": {
"allow": [
"read",
"write",
"edit",
"web_search",
"image",
"browser"
]
}
}
}
}
四、重启 Gateway
openclaw gateway restart
五、测试浏览器
查看状态:openclaw browser status
启动浏览器:openclaw browser start
打开网页:openclaw browser open https://example.com
六、常见问题
Q1: Gateway 启动超时
现象:Error: gateway timeout after 15000ms
解决:openclaw doctor --fix
openclaw gateway start
Q2: 浏览器启动失败
现象:running: false
解决:1. 确认 noSandbox: true 已设置
2. 检查浏览器路径是否正确
3. 确认 Playwright 浏览器已安装
Q3: 还是报 chrome extension 错误
原因:没有设置 defaultProfile: "openclaw"
解决:确保配置文件中有 "defaultProfile": "openclaw"
七、VPS 特别注意事项
必须使用 headless 模式 - VPS 没有图形界面
可能需要 noSandbox - 某些 Docker/VPS 环境需要
不要用 chrome profile - 那是给本地带扩展的浏览器用的
检查端口占用 - 默认 CDP 端口 18792,确保没被占用
八、验证成功
配置成功后,openclaw browser status 应该显示:
{
"enabled": true,
"profile": "openclaw",
"running": true,
"cdpReady": true,
"headless": true,
"noSandbox": true
}
九、参考资料
OpenClaw 官方文档:https://docs.openclaw.ai/tools/browser
Browser Setup Guide (GitHub Gist)
Playwright 文档:https://playwright.dev/
配置完成后,AI 助手就可以直接调用 browser 工具浏览网页、截图、自动化操作了!
云南聚优阁