#gateway close after starting
1 messages · Page 1 of 1 (latest)
Pra entender por que o Gateway “fecha” logo depois de iniciar, o que resolve mais rápido é pegar o motivo do exit no status/log. Consegue rodar isso na máquina onde o Gateway está rodando e colar aqui a saída?
openclaw --version
node --version
openclaw gateway status
openclaw status --all
openclaw logs --follow
# (deixa rodando até o gateway fechar e copia as últimas ~30-50 linhas)
openclaw doctor
Coisas bem comuns que fazem o Gateway encerrar logo após subir (e que vão aparecer aí em cima):
- Node < 22 (precisa Node >= 22).
- Service/config mismatch (no
openclaw gateway statusapareceConfig (cli)diferente deConfig (service)). - Porta em uso (
EADDRINUSE/ “another gateway instance is already listening”). - Bind sem auth (ex.: tentando bind em LAN/tailnet “sem token/senha” → recusa e sai).
gateway.modenão está"local"(aparece como “Gateway start blocked…”).
Também me diz: você está iniciando com serviço/daemon (openclaw gateway start/restart) ou rodando no terminal (openclaw gateway)? E qual OS (Linux/macOS/Windows/WSL)?
┌─────────────────┬──────────────────────────────────────────────────────────em │ Value │
├
│ Version │ 2026.2.14 │
│ OS │ windows 10.0.26200 (x64) │
│ Node │ 24.13.0 │
│ Config │ ~.openclaw\openclaw.json │
│ Dashboard │ http://192.168.68.51:18789/ │
│ Tailscale │ off │
│ Channel │ stable (config) │
│ Update │ pnpm · npm latest 2026.2.14 │
│ Gateway │ local · ws://192.168.68.51:18789 (local lan 192.168.68.51) · unreachable (connect failed: │
│ │ pairing required) │
│ Security │ Run: openclaw security audit --deep │
│ Gateway self │ unknown │
│ Gateway service │ Scheduled Task installed · registered · stopped │
│ Node service │ Scheduled Task not installed │
│ Agents │ 1 total · 0 bootstrapping · 0 active · 0 sessions │
└
Agents
┌────────────┬───────────┬──────────┬──────────┬──────────────────────────────────────────────────────────────────────┐
│ Agent │ Bootstrap │ Sessions │ Active │ Store │
├────────────┼───────────┼──────────┼──────────┼──────────────────────────────────────────────────────────────────────┤
│ main │ OK │ 0 │ unknown │ ~.openclaw\agents\main\sessions\sessions.json │
└────────────┴───────────┴──────────┴──────────┴──────────────────────────────────────────────────────────────────────┘
Diagnosis (read-only)
Gateway connection details:
Gateway target: ws://192.168.68.51:18789
Source: local lan 192.168.68.51
Config: C:\Users\hcosc.openclaw\openclaw.json
Bind: lan
✓ Config: C:\Users\hcosc.openclaw\openclaw.json
✓ Restart sentinel: none
! Port 18789
Port 18789 is already in use.
- pid 4372: unknown (0.0.0.0:18789)
- Another process is listening on this port.
! Tailscale: off · unknown
error: Error: spawn tailscale ENOENT
✓ Skills: 7 eligible · 0 missing · C:\home\hcosc.openclaw\workspace
! Channel issues skipped (gateway unreachable)
Gateway health:
connect failed: pairing required
Pasteable debug report. Auth tokens redacted.
Troubleshooting: https://docs.openclaw.ai/troubleshooting
🦞 OpenClaw 2026.2.14 (c1feda1) — End-to-end encrypted, drama-to-drama excluded.
|
gateway connect failed: Error: unauthorized: device token mismatch (rotate/reissue device token)
o
Service: Scheduled Task (registered)
File logs: \tmp\openclaw\openclaw-2026-02-16.log
Command: C:\Program Files\nodejs\node.exe C:\Users\hcosc\AppData\Roaming\npm\node_modules\openclaw\dist\index.js gateway --port 18789
Service env: OPENCLAW_GATEWAY_PORT=18789
Config (cli): ~.openclaw\openclaw.json
Config (service): ~.openclaw\openclaw.json
Gateway: bind=lan (0.0.0.0), port=18789 (service args)
Probe target: ws://192.168.68.51:18789
Dashboard: http://192.168.68.51:18789/
Probe note: bind=lan listens on 0.0.0.0 (all interfaces); probing via 192.168.68.51.
Runtime: stopped (state Pronto)
RPC probe: failed
RPC target: ws://192.168.68.51:18789
gateway closed (1008): unauthorized: device token mismatch (rotate/reissue device token)
Gateway target: ws://192.168.68.51:18789
Source: cli --url
Config: C:\Users\hcosc.openclaw\openclaw.json
Service is loaded but not running (likely exited immediately).
File logs: \tmp\openclaw\openclaw-2026-02-16.log
Logs: schtasks /Query /TN "OpenClaw Gateway" /V /FO LIST
Port 18789 is already in use.
- pid 4372: unknown (0.0.0.0:18789)
- Another process is listening on this port.
Listening: 0.0.0.0:18789
Troubles: run openclaw status
Troubleshooting: https://docs.openclaw.ai/troubleshooting
PS C:\Windows\System32>
Isso aí não parece “gateway fechando” — ele está recusando a conexão do seu cliente/UI com:
unreachable (connect failed: pairing required)
Ou seja: o Gateway está de pé o suficiente pra responder, mas como você está acessando pelo IP da LAN (192.168.68.51), ele exige pareamento de dispositivo (segurança). Em 127.0.0.1 ele costuma auto-aprovar.
Opção A (mais fácil, no mesmo PC do Gateway)
Abra o painel por loopback:
- http://127.0.0.1:18789/ (ou
http://localhost:18789/)
Opção B (acessando de outro dispositivo na rede / via IP LAN)
No PC do Gateway, rode:
openclaw devices list
openclaw devices approve <requestId>
Depois recarrega o dashboard / tenta de novo o openclaw status.
Observação
Seu status também mostra: “Gateway service … stopped” (Scheduled Task). Então, se você quer ele rodando “como serviço”, inicia/reinicia com:
openclaw gateway start
# ou
openclaw gateway restart
Se você colar a saída de openclaw devices list (pode ocultar nomes se quiser), eu te digo exatamente qual requestId aprovar.
Pelo que você colou, tem 2 problemas diferentes acontecendo — e um deles faz o “gateway fechar” na hora:
1) Porta 18789 já está em uso (isso faz o serviço sair)
O diagnóstico mostrou:
- Port 18789 is already in use
- pid 4372 escutando em
0.0.0.0:18789
Então quando o Scheduled Task (“OpenClaw Gateway”) tenta subir, ele não consegue bindar a porta e encerra.
No Windows, identifica quem é esse PID e para ele:
PowerShell / CMD:
netstat -ano | findstr :18789
tasklist /FI "PID eq 4372"
Se aparecer que é o node.exe/openclaw antigo, você pode finalizar esse processo (pelo Gerenciador de Tarefas ou via taskkill). Se não for OpenClaw, então é outro app usando a porta — e aí você precisa parar esse app ou trocar a porta do Gateway.
Depois disso, tenta subir de novo:
openclaw gateway restart
openclaw gateway status
2) “pairing required” / “device token mismatch” (auth/pareamento do dashboard)
Esses erros geralmente acontecem quando você acessa pelo IP da LAN (http://192.168.68.51:18789/), porque aí o Gateway trata como “conexão remota” e exige pareamento.
Para testar sem dor de cabeça no mesmo PC do gateway, abre:
Se você precisa acessar pelo IP LAN mesmo, aprova o pareamento:
openclaw devices list
openclaw devices approve <requestId>
E sobre unauthorized: device token mismatch: isso quase sempre é token salvo errado (no Control UI) ou você estava sem querer conectando em outro processo (o que combina com a porta em uso). Depois de resolver a porta 18789, isso costuma sumir.
Se ainda continuar, me manda o output de:
openclaw devices list
(e não cole nenhum token/segredo aqui).
Erro 1006
1006 no WebSocket = “abnormal closure” (o cliente perdeu a conexão sem receber um close reason do servidor). Ele quase nunca é a causa — é sintoma de:
- Gateway caiu/reiniciou, ou
- você conectou em algo que não é o Gateway (porta errada / outro processo), ou
- queda de rede/firewall, ou
- o Gateway fechou com
1008(ex.: pairing required / unauthorized) mas o browser só mostrou1006.
No seu caso anterior já apareceu porta 18789 em uso (PID 4372) + pairing/auth, então eu atacaria assim:
1) Resolver a porta 18789 (isso pode derrubar o serviço)
No Windows:
netstat -ano | findstr :18789
tasklist /FI "PID eq 4372"
Se for um node.exe/OpenClaw antigo, finalize esse processo (ou pare o app) e depois:
openclaw gateway restart
openclaw gateway status
2) Fazer o pareamento usando loopback (evita “pairing required”)
Quando você conecta via 192.168... o Gateway pede pairing. Para listar/aprovar sem dor, force localhost:
openclaw devices list --url ws://127.0.0.1:18789
openclaw devices approve <requestId> --url ws://127.0.0.1:18789
E abra o dashboard por:
http://127.0.0.1:18789/
3) Se ainda aparecer 1006: precisamos do motivo real no log
Cole as últimas ~40 linhas do arquivo:
C:\tmp\openclaw\openclaw-2026-02-16.log(ou o mais recente emC:\tmp\openclaw\)
e também o output de:
openclaw gateway status
Aí dá pra dizer exatamente se foi crash, conflito de porta, ou fechamento por auth/pairing.
Docs: https://docs.openclaw.ai/web/control-ui#device-pairing-first-connection
🦞 OpenClaw 2026.2.14 (c1feda1) — I can't fix your code taste, but I can fix your build and your backlog.
│
gateway connect failed: Error: unauthorized: device token mismatch (rotate/reissue device token)
◇
Service: systemd (enabled)
File logs: /tmp/openclaw/openclaw-2026-02-16.log
Command: /home/hcosc/.nvm/versions/node/v24.13.1/bin/node /home/hcosc/.nvm/versions/node/v24.13.1/lib/node_modules/openclaw/dist/index.js gateway --port 18789
Service file: ~/.config/systemd/user/openclaw-gateway.service
Service env: OPENCLAW_GATEWAY_PORT=18789
Service config looks out of date or non-standard.
Service config issue: Gateway service uses Node from a version manager; it can break after upgrades. (/home/hcosc/.nvm/versions/node/v24.13.1/bin/node)
Service config issue: System Node 22+ not found; install it before migrating away from version managers.
Recommendation: run "openclaw doctor" (or "openclaw doctor --repair").
Config (cli): ~/.openclaw/openclaw.json
Config (service): ~/.openclaw/openclaw.json
Gateway: bind=lan (0.0.0.0), port=18789 (service args)
Probe target: ws://172.22.159.14:18789
Dashboard: http://172.22.159.14:18789/
Probe note: bind=lan listens on 0.0.0.0 (all interfaces); probing via 172.22.159.14.
Runtime: running (pid 2640, state active, sub running, last exit 0, reason 0)
Warm-up: launch agents can take a few seconds. Try again shortly.
RPC probe: failed
RPC target: ws://172.22.159.14:18789
gateway closed (1008): unauthorized: device token mismatch (rotate/reissue device token)
Gateway target: ws://172.22.159.14:18789
Source: cli --url
Config: /home/hcosc/.openclaw/openclaw.json
Port 18789 is already in use.
- pid 2640 hcosc: openclaw-gateway (*:18789)
- Gateway already running locally. Stop it (openclaw gateway stop) or use a different port.
Listening: *:18789
Troubles: run openclaw status
Troubleshooting: https://docs.openclaw.ai/troubleshooting
hcosc@Queridao:~$
1006 é só “conexão WS caiu sem close-frame”. No seu log o motivo real está logo abaixo:
gateway closed (1008): unauthorized: device token mismatch (rotate/reissue device token)
Ou seja: o Gateway está rodando, mas o cliente (CLI/dashboard) está tentando autenticar com um token errado/antigo (muito comum em WSL quando você troca URL/IP ou reaproveita token salvo).
1) Se você está em WSL (172.22.x.x), use localhost no Windows
Em vez de http://172.22.159.14:18789/, abra:
- http://localhost:18789/ (ou
http://127.0.0.1:18789/)
Isso evita vários problemas de “pairing/secure context” e costuma parar esses 1006.
2) Corrigir o “device token mismatch”
No host do Gateway, rode: