Skip to content

MacOS hostname drift issue #318

@swickson

Description

@swickson

On macOS, the system hostname can silently change between reboots or network transitions. This is particularly common in setups where:

  • The dock and wireless network are on separate VLANs, each assigning a different IP and hostname
  • Rebooting away from the home network causes macOS to revert to the default computer name (e.g. macbook-dock.internalmacbook-wireless.internal)

When this happens, agents in the registry retain the old hostname as their hostId. The current normalizeHostId() function only performs basic string normalization (lowercase, strip .local suffix) — it has no awareness that a stale hostname still refers to the local machine.

Impact

  • Broken mesh visibility — remote peers can't match local agents to the correct host
  • AMP messages fall back to relay instead of direct mesh delivery
  • Wake/hibernate failures — agents with stale hostIds are treated as "remote" and the server proxies to itself, returning "unreachable"
  • Startup failurescreateSession() can inherit a stale TMUX env var from a parent tmux session that no longer exists after reboot

Proposed fix

  • normalizeHostId() and needsHostIdNormalization() should call isSelf(), which checks the hostname against all known aliases and local IPs in the hosts config. If a hostId is recognized as this machine but doesn't match the current hostname, it should be automatically migrated to the canonical self ID.
  • createSession() should unset the TMUX env var to prevent stale parent socket errors.
  • Additionally, validateHosts() should preserve old hostnames as aliases during self-host migration, and registerPeer()/syncWithAllPeers() should detect and migrate peer hostname changes instead of silently treating them as "already known."

We have a working fix in our fork and are happy to open a PR if there's interest.

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