Skip to content

macOS: ConnectError when connecting to local HA instance via Claude Desktop (Local Network permission + http vs https) #867

Description

@OscarAlmgren

Environment

  • Home Assistant: Running in container mode (Docker/K3s) on a local server (wardrobe/home server, same LAN)
  • HA MCP server: ha-mcp via uvx ha-mcp@latest configured in claude_desktop_config.json
  • Client: macOS (Sequoia 15), Claude Desktop
  • Network: HA server and Mac on the same local network (e.g. 192.168.0.x)

Problem

After correctly configuring claude_desktop_config.json with a valid HOMEASSISTANT_URL and HOMEASSISTANT_TOKEN, every tool call fails with:

ConnectError: All connection attempts failed
HomeAssistantConnectionError: Failed to connect to Home Assistant: All connection attempts failed

The MCP server starts successfully, tools are listed, but any actual tool call (e.g. ha_get_overview) fails immediately.

Root Causes Found

1. macOS Local Network permission blocks subprocess connections

Claude Desktop spawns uvx as a child process. macOS silently blocks outbound TCP connections to local network IPs (192.168.x.x, 10.x.x.x, etc.) for subprocesses spawned by apps that haven't been granted Local Network permission.

Crucially, no permission dialog is shown for CLI subprocesses — the connection just fails. Claude Desktop itself does not appear in System Settings → Privacy & Security → Local Network, so there is no way to grant the permission manually.

This means HOMEASSISTANT_URL=http://192.168.0.x:8123 will always fail when ha-mcp is invoked from Claude Desktop on macOS, regardless of whether the URL and token are correct.

Verification: The same Python environment (uvx's cached Python) can reach the HA API fine when run directly from Terminal — but not when spawned by Claude Desktop.

2. https:// vs http:// — HA container mode uses HTTP by default

HA running in container mode (not HAOS or Supervised) does not configure SSL/TLS by default. Using https:// in HOMEASSISTANT_URL causes a TLS handshake error:

error:1404B42E:SSL routines:ST_CONNECT:tlsv1 alert protocol version

Use http:// unless you have explicitly configured a reverse proxy with TLS.

Workaround: SSH tunnel to localhost

Since macOS does not restrict connections to localhost, an SSH port forward bypasses the Local Network permission block entirely.

One-time test:

ssh -N -L 8123:localhost:8123 user@your-ha-server

Then set HOMEASSISTANT_URL=http://localhost:8123 in your config.

Persistent (macOS LaunchAgent) — survives reboots and auto-reconnects:

Create ~/Library/LaunchAgents/com.user.ha-tunnel.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.user.ha-tunnel</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/ssh</string>
        <string>-N</string>
        <string>-o</string><string>StrictHostKeyChecking=no</string>
        <string>-o</string><string>ExitOnForwardFailure=yes</string>
        <string>-o</string><string>ServerAliveInterval=30</string>
        <string>-o</string><string>ServerAliveCountMax=3</string>
        <string>-L</string><string>8123:localhost:8123</string>
        <string>user@192.168.0.x</string>
    </array>
    <key>RunAtLoad</key><true/>
    <key>KeepAlive</key><true/>
</dict>
</plist>

Load it:

launchctl load ~/Library/LaunchAgents/com.user.ha-tunnel.plist

Update claude_desktop_config.json:

{
  "mcpServers": {
    "Home Assistant": {
      "command": "uvx",
      "args": ["ha-mcp@latest"],
      "env": {
        "HOMEASSISTANT_URL": "http://localhost:8123",
        "HOMEASSISTANT_TOKEN": "your-token-here"
      }
    }
  }
}

Suggested Doc Addition

A macOS troubleshooting section covering:

  • Use http:// not https:// for container-mode HA without a TLS reverse proxy
  • If on the same LAN as your HA server, use an SSH tunnel to localhost to bypass macOS Local Network permission restrictions on Claude Desktop subprocesses
  • Symptom to look for: ConnectError: All connection attempts failed despite correct URL and token (confirmed working from Terminal)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingdocumentationImprovements or additions to documentationtriaged

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions