Files
bot/docs/tools/browser-linux-troubleshooting.md
zeekayandHanzo Dev 84e4069c2c docs name the state dir and config file the bot reads: ~/.bot/bot.json
The docs said ~/.hanzo-bot/hanzo-bot.json (and ~/.hanzo-bot-<profile>, hanzo-bot.plugin.json), which nothing reads: src/config/paths.ts resolves ~/.bot, bot.json and ~/.bot-<profile>, and plugins ship bot.plugin.json. Every such path in docs/ now names what the code opens.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-24 21:12:09 -07:00

4.7 KiB
Raw Permalink Blame History

summary, read_when, title
summary read_when title
Fix Chrome/Brave/Edge/Chromium CDP startup issues for HanzoBot browser control on Linux Browser control fails on Linux, especially with snap Chromium Browser Troubleshooting

Browser Troubleshooting (Linux)

Problem: "Failed to start Chrome CDP on port 18800"

HanzoBot's browser control server fails to launch Chrome/Brave/Edge/Chromium with the error:

{"error":"Error: Failed to start Chrome CDP on port 18800 for profile \"hanzo-bot\"."}

Root Cause

On Ubuntu (and many Linux distros), the default Chromium installation is a snap package. Snap's AppArmor confinement interferes with how HanzoBot spawns and monitors the browser process.

The apt install chromium command installs a stub package that redirects to snap:

Note, selecting 'chromium-browser' instead of 'chromium'
chromium-browser is already the newest version (2:1snap1-0ubuntu2).

This is NOT a real browser — it's just a wrapper.

Install the official Google Chrome .deb package, which is not sandboxed by snap:

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb
sudo apt --fix-broken install -y  # if there are dependency errors

Then update your HanzoBot config (~/.bot/bot.json):

{
  "browser": {
    "enabled": true,
    "executablePath": "/usr/bin/google-chrome-stable",
    "headless": true,
    "noSandbox": true
  }
}

Solution 2: Use Snap Chromium with Attach-Only Mode

If you must use snap Chromium, configure HanzoBot to attach to a manually-started browser:

  1. Update config:
{
  "browser": {
    "enabled": true,
    "attachOnly": true,
    "headless": true,
    "noSandbox": true
  }
}
  1. Start Chromium manually:
chromium-browser --headless --no-sandbox --disable-gpu \
  --remote-debugging-port=18800 \
  --user-data-dir=$HOME/.bot/browser/hanzo-bot/user-data \
  about:blank &
  1. Optionally create a systemd user service to auto-start Chrome:
# ~/.config/systemd/user/hanzo-bot-browser.service
[Unit]
Description=HanzoBot Browser (Chrome CDP)
After=network.target

[Service]
ExecStart=/snap/bin/chromium --headless --no-sandbox --disable-gpu --remote-debugging-port=18800 --user-data-dir=%h/.hanzo-bot/browser/hanzo-bot/user-data about:blank
Restart=on-failure
RestartSec=5

[Install]
WantedBy=default.target

Enable with: systemctl --user enable --now hanzo-bot-browser.service

Verifying the Browser Works

Check status:

curl -s http://127.0.0.1:18791/ | jq '{running, pid, chosenBrowser}'

Test browsing:

curl -s -X POST http://127.0.0.1:18791/start
curl -s http://127.0.0.1:18791/tabs

Config Reference

Option Description Default
browser.enabled Enable browser control true
browser.executablePath Path to a Chromium-based browser binary (Chrome/Brave/Edge/Chromium) auto-detected (prefers default browser when Chromium-based)
browser.headless Run without GUI false
browser.noSandbox Add --no-sandbox flag (needed for some Linux setups) false
browser.attachOnly Don't launch browser, only attach to existing false
browser.cdpPort Chrome DevTools Protocol port 18800

Problem: "Chrome extension relay is running, but no tab is connected"

You’re using the chrome profile (extension relay). It expects the HanzoBot browser extension to be attached to a live tab.

Fix options:

  1. Use the managed browser: hanzo-bot browser start --browser-profile hanzo-bot (or set browser.defaultProfile: "hanzo-bot").
  2. Use the extension relay: install the extension, open a tab, and click the HanzoBot extension icon to attach it.

Notes:

  • The chrome profile uses your system default Chromium browser when possible.
  • Local hanzo-bot profiles auto-assign cdpPort/cdpUrl; only set those for remote CDP.