Skip to content

TUI gateway connection ignores bind mode, hardcodes localhost #16299

@cortexuvula

Description

@cortexuvula

Summary

The TUI's gateway connection logic hardcodes ws://127.0.0.1:${localPort} and does not respect the gateway.bind config setting, while the status command correctly uses pickProbeHostForBind() to resolve the actual bind address.

Root Cause

In src/tui/gateway-chat.ts, the resolveGatewayConnection() function at line 241 hardcodes the fallback URL:

const localUrl = `ws://127.0.0.1:${localPort}`;

This does not consult the bind mode at all, unlike the status/probe code which correctly uses pickProbeHostForBind().

Steps to Reproduce

  1. Configure gateway to bind only to Tailscale: openclaw config set gateway.bind tailnet
  2. Restart gateway (now listening only on Tailscale IP, e.g., 100.97.87.117:18789)
  3. Try to connect via TUI: openclaw tui
  4. Connection fails - TUI tries localhost, but gateway isn't listening there

Current Workaround

Change bind back to loopback:

openclaw config set gateway.bind loopback

This works but breaks remote access from the Tailnet.

Proposed Fix

Make resolveGatewayConnection() resolve the gateway host based on the bind mode from config, just like pickProbeHostForBind() does.

Required changes:

  1. Import pickPrimaryTailnetIPv4 from ../infra/tailnet.js
  2. Import pickPrimaryLanIPv4 from ../gateway/net.js
  3. Import GatewayBindMode type
  4. Resolve host based on config.bind mode instead of hardcoding 127.0.0.1

Impact

  • Users cannot use TUI when gateway is bound to tailnet or LAN only
  • Inconsistent behavior between status command (works) and TUI (broken)

Environment

  • OpenClaw version: latest (as of 2026-02-14)
  • Platform: Linux
  • Config: gateway.bind: "tailnet"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions